Reputation: 119
My code:
$videos_key = array();
foreach($result[$x]["videos_key"] as $videoskey => $result[$x]["videos_key"] )
{
$videos_key[$videoskey] = $result[$x]["videos_key"];
}
print_r($videos_key);
I want to store all values inside $result[$x]["videos_key"]
to $videos_key
variable
But i am getting this error:
Warning: Invalid argument supplied for foreach()
Upvotes: 0
Views: 1227
Reputation: 27295
That syntax you use is to split your array in key value pairs.
$videos_key = array(
array('id' => 1, 'value' => 'test')
);
$video_keys_out = array();
foreach($videokey as $key => $value) {
$videos_keys_out[$key] = $value;
}
something like that. I don't know the rest of your code. So with that syntax you fetch the id and value keypair form the first array and you can work with them.
Upvotes: 2