Maybe an easy question, but I am having trouble with two arrays. I want each element in the 'test' array to represent an index in the 'foo' array. I hope this makes sense.
<?php
$test = array(1=>50,60,70);
$foo = array('age', 'money', 'number');
?>
Try this:
$new_array = array_combine($test, $foo);
echo "<pre>";
print_r($new_array);
echo "</pre>";
This gives:
Array
(
[50] => age
[60] => money
[70] => number
)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.