array-key

Is it okay to use array[key] in PHP?

Hi, I have a simple question. Is it okay to use array without single or double quotion like $array[key]? I thought it is bad because PHP look for constant first if I don't use single or doulbe quotion. One of my colleagues told me that it does not matter. WHat do you guys think? ...

array_key_exists is not working

array_key_exists is not working for large multidimensional array. For ex $arr=array( '1'=>10, '2'=>array('21'=>21, '22'=>22, '23'=>array('test'=>100, '231'=>231), ), '3'=>30, '4'=>40 ); array_key_exists('test',$arr) returns ...

C++ get array key in constructor of array of a custom class/struct?

If I have a simple class like this: class MyClass { MyClass(){} ~MyClass(){} public: int myArrayKeyValue; }; And later, I create an array of these classes: MyClass testing[10]; How, in the constructor, would I access the array key so I can set the myArrayKeyValue appropriately for each element of the array? So that I...

PHP array keys values

I have an array like this $data = array( "some => "163", "rand" => "630", "om" => "43", "words" => "924", "as" => "4", "keys" => "54" ); How can I get each set's key associated with their values like this: foreach ($data as $stuff){ $this->$stuff["key"] = $stuff["value"]; } ...

how to use in foreach for array_keys

hi Guys, i need to get data from array_keys the script i use in the server side: PHP: $friends = json_decode(file_get_contents( 'https://graph.facebook.com/me/friends?access_token=' . $facebook->getAccessToken() ), true); $friend_ids = array_keys($friends); the data of array look as above: { "data": [ { "name": ...