Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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 ajoutée par Anirban Chakraborty , Network Administrator , Wipro Limited
Date de publication: 2017/01/17
Utilisateur supprimé
par Utilisateur supprimé

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

Ahmed Sabra
par 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.

هاشم المشارقة
par هاشم المشارقة , 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