Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What is the problem with the code below? What will it output? How can it be fixed?

$referenceTable = array();

$referenceTable['val1'] = array(1,2);

$referenceTable['val2'] =3;

$referenceTable['val3'] = array(4,5);

 

$testArray = array();

 

$testArray = array_merge($testArray, $referenceTable['val1']);

var_dump($testArray);

$testArray = array_merge($testArray, $referenceTable['val2']);

var_dump($testArray);

$testArray = array_merge($testArray, $referenceTable['val3']);

var_dump($testArray);

user-image
Question added by Anirban Chakraborty , Network Administrator , Wipro Limited
Date Posted: 2017/01/17

answer here ......................

Ahmed Sabra
by Ahmed Sabra , Integration Support Engineer- Fintech , Saudi Financial Technology Company

As $referenceTable['val2'] isn't an array, then array_merge function failed to merge it with $testArray.

هاشم المشارقة
by هاشم المشارقة , Key Account Manager , Advanced United Systems Ltd. ( A member of Taj Holding Group)

Could you first clarify what does the following function do ?

var_dump($testArray);

 

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.