JSON Decode - returns the undefined index

Am trying to get more familiar with JSON decoding, so here's what I got: $json = '{"id":[{"tier": "SILVER"}]}'; $array = json_decode($json, true); var_dump($array["id"]['tier']); I am trying to fetch the 'tier', but

Setinterval with exponential reduction of time

I've got a mousedown event with a setinterval. I want the time of intervals to be variable. So the first one is 500, the second one 500/2 = 250, etc. Any tips? $plus.mousedown(function(e) { increment(20) timeout = setInterval(function(){ increment(20

Remove suffixes from numbers

I'm looking for a way to remove suffixes "m", "k", "b", or "%" from numbers in Javascript. I've successfully matched all digits which are followed by the letters I care about: \b[\d\.]+[mkb%]\b Debuggex Demo Given t

Prevent caching after pages are updated every x seconds

I'm building a news app. I refresh a div with the class of .new_feed every 10 seconds, to check for new updates, and when there is it shows up. Now the problem is, when there is a new feed in it, and the 10 seconds is up, and you don't click to see,

Spaces to tabs in Visual Studio code

I writing typescript and html files, and the tabs become to spaces. It's the first time I am using Visual Studio Code. I tried to change the settings and restart, but nothing changed. The settings i configured: // Place your settings in this file to

declaration prepared invalid parameter number

Okay so I've been starting at this for an hour now, it says "Invalid parameter number: number of bound variables does not match number of tokens in..." Iv'e counted them out and they are right. Any ideas? $sql="insert into myTable (TicketID

Random color production with PHP

I'm trying to generate random HTML colors in PHP, but I'm having trouble getting them to look similar, or in the same family. Is there some function I can use to generate colors that are "similar" to another color, besides just generating and co

Scroll div left content right mouseover

Good day. I need script that will follow the mouse and will scroll content depending on what side mouse is. If left then left, if right then right. I need it for cases when line of hrefs will exceed width of block, like here http://cloud.ignatynikuli

sentences in a Lambda expression

I'm starting with Lambda Expressions to understand how to define anonymous methods using it. I have the following simple code: delegate void AddNumber(int number); class LambdaExpressionSample { static void Main(string[] args) { AddNumber method = r

Using CoreBluetooth in iOS

I'm preparing implement app for bluetooth LE. But I still not understand it clearly. I have any questions about it. Could you please help me explain: What's central and Peripherals mode? I downloaded many source code about Bluetooth and see them impl

Can I use solr per se

I'm building a search engine and need to crawl the web, index it and be able to search the data. Can I use Apache Solr by itself or do I need Nutch first to crawl the web?You need a crawler to gather the content, so Solr can index it. Nutch and Crawl

Pass parameters in C with & without & ldquo; & rdquo;

How can i recognize if a parameter is passing with or without " ". For example: $ ./a.out "Hello I am chain of characters with spaces" $ ./a.out Hello I am not a chain of characters with spaces The quotes are parsed and handled by (in

Query element class on the angular directive 2

I am new to Angular 2 and I want to write a attribute directive that query the element searching for 'class1' class, if it is found then it should replace 'class1' with 'class2'. Should look like this: import {Directive, ElementRef, Renderer, Input}

Java Generics - raw type and parameterized type conversion

I've been reading Java Generics Tutorials and few threads in Stackoverflow that deal with Generics, and still could not understand a specific case. Here it is: public class Box<T> { private T t; public T getT () { return t; } public void setT (T t)

Reading an entire file in binary mode using C ++

I am trying to read an entire jpg file in binary mode using visual c++. The code is as follows: FILE *fd = fopen("c:\\Temp\\img.jpg", "rb"); if(fd == NULL) { cerr << "Error opening file\n"; return; } fseek(fd, 0, SEEK_E

JSON jQuery issue: Uncaught SyntaxError: unexpected token:

I am writing a jQuery call to retrieve JSON data from the memegenerator.net API. However, using the code below, I get a Uncaught SyntaxError: Unexpected token : error whenever I test it in Chrome. I tried removing the callback=? and that threw anothe

OnClickListener to the Fragment class

if i click FridgeWarningStatus Fragment then it will occupy full screen? how can i do that??? please any one help me thanks in Advance public class FridgeContainer extends Fragment { private View view; private FridgeTimerStatus fridgeTimerStatus; pri

BufferedReader readLine () blocks

When receiving data using readLine(), even though I put a "\n" at the end of the message using the .flush when sending the message, the while loop that reads my message still blocks. Only when closing the socket connection, it leaves the loop. H

ORDER BY timestring as time instead of string

I have a table with a column of times such as | time| |=====| | 9:20| |14:33| | 7:35| In my query, I have ORDER BY time, but it sorts the times as strings, so the result is ordered as |14:33| | 7:35| | 9:20| What do I have to do to my ORDER BY statem

How to create a link in HTML with href as its content

I think it is clear but here is an example: <a href="https://stackoverflow.com/">https://stackoverflow.com/</a> The code makes this real link: https://stackoverflow.com/ Is there a simpler way to do this?I take it you want something

node.js database queries in order

I'd like to perform queries in order but I don't know what is the best approach. Let's say I'd like to do the following : if (name) { //first query db.query({name:name}).exec(function(err,result) { //save result }) } if (isEmpty(result)) { //make ano