I have a PHP array like
$arr = array("c_m_email" => "a@b.z");
and I can access the email by
$arr['c_m_email']
But is there another way to just write $arr[0]
?
I have a PHP array like
$arr = array("c_m_email" => "a@b.z");
and I can access the email by
$arr['c_m_email']
But is there another way to just write $arr[0]
?
Use array_values()
array_values() returns all the values from the array and indexes the array numerically.
If you want the first entry in the array, you could also do this:
reset($h);
echo current($h)
$i=0;
$data=array();
foreach($arr as $value){
$data[$i] = $value;
$i++;
}
print_r($data);