Kombinieren Sie zwei flache Arrays zu Schlüsselwertpaaren eines neuen assoziativen ArraysPhp

PHP-Programmierer chatten hier
Guest
 Kombinieren Sie zwei flache Arrays zu Schlüsselwertpaaren eines neuen assoziativen Arrays

Post by Guest »

Code: Select all

$fruit = array(0 => "Lemon", 1 => "Apple");
$order = array(0 => "no1", 1 => "no2");
$new_array = array();
foreach ($order as $index) {
$new_array[$index] = $fruit[$index];
}
print_r($new_array);
Es zeigt:

Code: Select all

Notice: Undefined index: no1 in C:\xampp\htdocs\jobs.php on line 6
Notice: Undefined index: no2 in C:\xampp\htdocs\jobs.php on line 6
Was soll ich tun?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post