"163", "rand" => "630", "om" => "43", "words" => "924", "as" => "4", "key...">

PHP array key 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 installation key associated with their values as follows:

 foreach ($data as $stuff){ $this->$stuff["key"] = $stuff["value"]; } 
+6
arrays php foreach key array-key
source share
2 answers
 foreach ($data as $key => $value){ echo "$key => $value\n"; } 
+16
source share
 foreach($data as $key => $value) { // $key and $value variable are available here // First iteration values would be: $key = "some" and $value = "163" } 
+5
source share

All Articles