I am trying to remove the second element from every row of multidimensional array. I have only found solutions to remove the last array or to remove the last column. Here's my latest trying, but doesn't work now... Can you help me?
<?php
$array = [
["item_id" => "1", "item_name" => "a"],
["item_id" => "2", "item_name" => "b"],
["item_id" => "3", "item_name" => "c"],
["item_id" => "4", "item_name" => "d", "value" => "10"],
["item_id" => "5", "item_name" => "e", "value" => "11"],
["item_id" => "6", "item_name" => "f", "value" => "12"]
];
foreach($array AS $row)
{
unset ($row[count($row)-2]);
}
print_r($array);
?>
My desired output is:
$array = [
["item_id" => "1"],
["item_id" => "2"],
["item_id" => "3"],
["item_id" => "4", "value" => "10"],
["item_id" => "5", "value" => "11"],
["item_id" => "6", "value" => "12"]
];