#41392 [Opn->Fbk]: Putting pointers to array A from array B will destroy pointer with explode()

From: Date: Tue, 15 May 2007 03:16:36 +0000
Subject: #41392 [Opn->Fbk]: Putting pointers to array A from array B will destroy pointer with explode()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112639@lists.php.net to get a copy of this message
ID: 41392 Updated by: scottmac@php.net Reported By: hscdaunte at hotmail dot com -Status: Open +Status: Feedback Bug Type: Arrays related Operating System: Win 2003 Enterprise PHP Version: 5.2.2 New Comment: Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Previous Comments: ------------------------------------------------------------------------ [2007-05-15 03:09:52] hscdaunte at hotmail dot com 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 this bug report at http://bugs.php.net/?id=41392&edit=1

« previous php.bugs (#112639) next »