I have two arrays.
$a = array("one","two","three");
$b = array ( 0,1,2,3,4,5,6,7,8,9);
I have two arrays.
$a = array("one","two","three");
$b = array ( 0,1,2,3,4,5,6,7,8,9);
Look at the user contributed example in http://www.php.net/manual/en/class.infiniteiterator.php
$obj = new stdClass(); $obj->Mon = "Monday"; $obj->Tue = "Tuesday"; $obj->Wed = "Wednesday"; $obj->Thu = "Thursday"; $obj->Fri = "Friday"; $obj->Sat = "Saturday"; $obj->Sun = "Sunday"; $infinate = new InfiniteIterator(new ArrayIterator($obj)); foreach (new LimitIterator($infinate, 0, 14) as $value ) { print($value . PHP_EOL); }
You could create a mapping function and use array_map
as follows:
function numToName($num) {
return array("zero","one","two","three","four","five",
"six","seven","eight","nine")[$num];
}
$b = array (0,8,2,3,7,5,6,0,4,1);
$result = array_map("numToName", $b);
print_r($result);