note 47930 deleted from function.array by tularis

From: Date: Mon, 06 Dec 2004 10:28:10 +0000
Subject: note 47930 deleted from function.array by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-81433@lists.php.net to get a copy of this message
Note Submitter: dieptin44a at yahoo dot com ---- I copy this code for test: <?php $arr1 = ( 0 => array ("customer"=>"Client 1","Item a"), 1 => array ("customer"=>"Client 2","Item b") ); /*function to add elements*/ function addArray(&$array, $id, $var) { $tempArray = array( $var => $id); $array = array_merge ($array, $tempArray); } /*The same as above but the element is an array*/ function addArrayArr(&$array, $var, &$array1) { $tempArray = array($var => $array1); $array = array_merge ($array, $tempArray); } /*labels of our array or heders of the file*/ $keyarr = array("customer","item"); /*info that may you read from a file line 1 and 2*/ $valarr0 = array("Client 1","Item a"); $valarr1 = array("Client 2","Item b"); $numofrows = 2;/*In our case is just two lines*/ $tmpArray = array(); for($i = 0; $i < $numofrows; $i++){ $tmp = "valarr$i"; $tmpvar = ${$tmp};/*Using var of vars tricky tricky*/ foreach( $keyarr as $key=>$value){ addArray($tmparr,$tmpvar[$key],$value); } addArrayArr($finalarr,$i,$tmparr); } /*voila all it's perfectly ordered on finalarr*/ /*Here we just print the info but you can insert it into a database*/ echo "Customer: ".$finalarr[0]["customer"]."<br>"; echo "Item: ".$finalarr[0]["item"]."<br>"; echo "Customer: ".$finalarr[1]["customer"]."<br>"; echo "Item: ".$finalarr[1]["item"]."<br>"; ?> Any ideas why I get : Parse error: syntax error, unexpected T_DOUBLE_ARROW in c:\AppServ\www\test\test.php on line 3 ???? ---- Reason: bad code

« previous php.notes (#81433) next »