if I have the array like that:
array(
array('id'=>123,'name'=>"Ele1"),
array('id'=>12233,'name'=>"Ele2"),
array('id'=>1003,'name'=>"Ele4"),
array('id'=>1233,'name'=>"Ele5")
)
That's the data I get and I want to effeciently remove 2nd value of every inner array. (e.g. "Ele1", "Ele2". .... )
here is what I do:
$numEle = count($arrayA);
$_arrayB = array();
for ($i=0; $i<$numEle ; $i++)
{
array_push($_arrayB , $arrayA[$i]['id']);
}
Instead of have a for loop to read and assign the value to a new array. What is the best way to do it? any php build-in function I should use?
like array_map?
I currently do that:
Thanks all for the answer. They all work. :)