Welcome to Interactive Programming Forums, where you can ask questions, receive answers from other members of the community, post code snippets and post exercies.

Warning: array_combine() expects parameter 1 to be array, null given - = - and other error: Undefined variable: mixed

0 votes
PHP → Arraysview exercises
Creating arrays
Examine and try out the following code:

$numbers=array(1,5,10);
$fruits=array('apple','banana','watermelon');
$mixed = array_combine($numbers,$fruits);
echo $mixed[10];

Welcome to Interactive PHP Programming Class
Type clear - to clear the screen

php> $numbers=array(1,5,10);
php> $fruits=array('apple', 'banana', 'watermelon');
php> $mixed = array_combine($numbers,$fruits);
Warning: array_combine() expects parameter 1 to be array, null given
php> echo $mixed[10];
PHP Notice: Undefined variable: mixed


What is wrong at this exercise ???? Please help. Someoane any ideas???
posted 5 years ago in PHP by SUNRISER (2,050 points)

1 Answer

+1 vote
Thanks for trying out code.he.net Beta.

Please run them as a single line(see below):

php> $numbers=array(1,5,10); $fruits=array('apple','banana','watermelon'); $mixed = array_combine($numbers,$fruits); echo $mixed[10];

Let us know if the problem continues.
answered 5 years ago by codeadmin (113,880 points)
Yes, the exception was caused by the compiler compile each line, so that it can not understand $number and $fruits

Related questions

+7 votes
1 answer
–1 vote
1 answer
posted 5 years ago in SQL by SUNRISER (2,050 points)
+4 votes
1 answer
posted 5 years ago in PHP by ansh1990 (1,640 points)
+4 votes
1 answer
posted 5 years ago in Python by Manuel Pacheco (1,280 points)