#41392 [NEW]: Putting pointers to array A from array B will destroy pointer with explode()

From: Date: Tue, 15 May 2007 03:09:53 +0000
Subject: #41392 [NEW]: Putting pointers to array A from array B will destroy pointer with explode()
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112636@lists.php.net to get a copy of this message
From: hscdaunte at hotmail dot com Operating system: Win 2003 Enterprise PHP version: 5.2.2 PHP Bug Type: Arrays related Bug description: Putting pointers to array A from array B will destroy pointer with explode() Description: ------------ When using the eplode function on top of array that has memory pointers pointing at it will not work. The new array generated by explode overwrites current memory location rather then assiging the new values to the current memory. Suffucient example is provided example output with 'XXXXX' were just removed for identity purposes. Reproduce code: --------------- //data assignments!!! $outgoing = array( "primtransactionid" => &$incoming[0], "origtransactionid" => &$incoming[1], "prnttransactionid" => &$incoming[2], "datecreated" => &$incoming[3], "productid" => &$incoming[4], "amount" => &$incoming[5], "firstname" => &$incoming[6], "lastname" => &$incoming[7], "address1" => &$incoming[8], "address2" => &$incoming[9], "city" => &$incoming[10], "state" => &$incoming[11], "zip" => &$incoming[12], "country" => &$incoming[13], "phonenumber" => &$incoming[14], "email" => &$incoming[15], "ipaddress" => &$incoming[16], "ssn" => &$incoming[17], "dob" => &$incoming[18], "maiden" => &$incoming[19], "field1" => &$incoming[20], "field2" => &$incoming[21], "stampprocess" => &$incoming[22], "status" => &$incoming[23], "completion" => &$incoming[24], "exception" => &$incoming[25], "exceptiondate" => &$incoming[26], ); //ebonus default settings per offer //section removed this area made a curl to a secure site to retrieve transactions each transaction is divided by a '\r\n' then each sub data is divided by a ';' like so the actual list is above Example: 111123;111123;john;doe;2007-04-03;C\r\n //end removed // get the data from the curl $post = new Post($_EPOST['efs01'], array()); //get the data retrieved from the curl and explode each transaction by '\r\n' $transactions = explode("\r\n", $post->result); //run each transaction foreach ($transactions as $id => $transaction) { //assign incoming the exploded data which should be pointed to with the outgoing pointers... incoming[0], incoming[1] etc... $incoming = explode(";", $transaction); //outgoing should display incomings data with the assoc array names created above... print_r($incoming); print_r($outgoing); die(); } Expected result: ---------------- This was the work around to make this work: foreach ($transactions as $id => $transaction) { $temp = explode(";", $transaction); foreach($temp as $id => $value) $incoming[$id] = $value; print_r($incoming); print_r($outgoing); die(); } Array ( [0] => 134661267834 [1] => 134661267834 [2] => [3] => 2007-03-20 00:00:35 [4] => 891231 [5] => 124.90 [6] => XXXXX [7] => rillon [8] => 41-956 XXXXX hwy [9] => [10] => waimanalo [11] => XX [12] => 96795 [13] => USA [14] => XXXXXX5963 [15] => chelsey96795@XXXXX.com [16] => 66.8.180.61 [17] => . [18] => [19] => [20] => [21] => [22] => 2007-03-20 13:51:10 [23] => C [24] => 2007-04-05 [25] => [26] => 0000-00-00 ) Array ( [primtransactionid] => 134661267834 [origtransactionid] => 134661267834 [prnttransactionid] => [datecreated] => 2007-03-20 00:00:35 [productid] => 891231 [amount] => 124.90 [firstname] => XXXXX [lastname] => rillon [address1] => 41-956 XXXXX hwy [address2] => [city] => waimanalo [state] => XX [zip] => 96795 [country] => USA [phonenumber] => XXXXXX5963 [email] => chelsey96795@removed.com [ipaddress] => 66.8.180.61 [ssn] => . [dob] => [maiden] => [field1] => [field2] => [stampprocess] => 2007-03-20 13:51:10 [status] => C [completion] => 2007-04-05 [exception] => [exceptiondate] => 0000-00-00 ) Actual result: -------------- Array ( [0] => 134661267834 [1] => 134661267834 [2] => [3] => 2007-03-20 00:00:35 [4] => 891231 [5] => 124.90 [6] => XXXXX [7] => rillon [8] => 41-956 XXXXX hwy [9] => [10] => waimanalo [11] => XX [12] => 96795 [13] => USA [14] => XXXXXX5963 [15] => chelsey96795@XXXXX.com [16] => 66.8.180.61 [17] => . [18] => [19] => [20] => [21] => [22] => 2007-03-20 13:51:10 [23] => C [24] => 2007-04-05 [25] => [26] => 0000-00-00 ) Array ( [primtransactionid] => [origtransactionid] => [prnttransactionid] => [datecreated] => [productid] => [amount] => [firstname] => [lastname] => [address1] => [address2] => [city] => [state] => [zip] => [country] => [phonenumber] => [email] => [ipaddress] => [ssn] => [dob] => [maiden] => [field1] => [field2] => [stampprocess] => [status] => [completion] => [exception] => [exceptiondate] => ) -- Edit bug report at http://bugs.php.net/?id=41392&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41392&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41392&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41392&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41392&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41392&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41392&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41392&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41392&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41392&r=support Expected behavior: http://bugs.php.net/fix.php?id=41392&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41392&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41392&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41392&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41392&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41392&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41392&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41392&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41392&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41392&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41392&r=mysqlcfg

« previous php.bugs (#112636) next »