How to get array value with a numeric index in php?
In this post, we used array_values() function in php to get the value of array by position with arrays with index of 1 key.
1. Code:
<?php $array = array('sol' => 'Soltuts', 33 => 'bin', 'lorem' => 'ipsum'); $array = array_values($array); echo $array[0]; //Soltuts echo $array[1]; //bin echo $array[2]; //ipsum ?>
2. Example:
Input:
Array('sol' => 'Soltuts', 33 => 'bin', 'lorem' => 'ipsum')
Output:
Array ( [0] => Soltuts [1] => bin [2] => ipsum )