How to handle an associative array to form an array of values?

There is an array

array(3) { 
[0]=> array(1) { ["id"]=> string(4) "1000" } 
[1]=> array(1) { ["id"]=> string(4) "1001" } 
[2]=> array(1) { ["id"]=> string(4) "1002" } 
}


It is necessary to remove from it everything except id bring it to mind [1000, 1001, 1002]. How can I do that?
March 12th 20 at 08:40
3 answers
March 12th 20 at 08:42
Solution
well here ponapisyval...
this is solved with one function https://secure.php.net/manual/ru/function.array-co...
March 12th 20 at 08:44
Solution
in php, you can:
$array = array(
 array("id" => 1),
 array("id" => 2),
 array("id" => 3),
);

foreach ($array as $value) {
 $new_array[] = $value["id"];
}

echo "<pre>";
print_r($new_array);
echo "</pre>";
Thank you! Tell me: what in case you do not know the number of elements in the first array? Maybe 3, maybe 100 - rodolfo69 commented on March 12th 20 at 08:47
Yes, even 1000, the script will still work - Mercedes.Kessler commented on March 12th 20 at 08:50
@Mercedes.Kessler, came! Thank you)) - rodolfo69 commented on March 12th 20 at 08:53
March 12th 20 at 08:46
array_combine

Find more questions by tags JavaScriptPHP