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

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Kombinieren Sie zwei flache Arrays zu Schlüsselwertpaaren eines neuen assoziativen Arrays

by Guest » 23 Feb 2025, 05:29

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?

Top