php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41392 Putting pointers to array A from array B will destroy pointer with explode()
Submitted: 2007-05-15 03:09 UTC Modified: 2007-05-17 09:58 UTC
From: hscdaunte at hotmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.2.2 OS: Win 2003 Enterprise
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hscdaunte at hotmail dot com
New email:
PHP Version: OS:

 

 [2007-05-15 03:09 UTC] 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] => 
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-15 03:16 UTC] scottmac@php.net
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.
 [2007-05-17 00:38 UTC] hscdaunte at hotmail dot com
<?
//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],
);

//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

// get the data from the curl however to replicate we are just going to provide the data this is one example row below
$data = "134661267834;134661267834;;2007-03-20 00:00:35;891231;124.90;XXXXX;rillon;41-956 XXXXX hwy;;waimanalo;XX;96795;USA;XXXXXX5963;chelsey96795@XXXXX.com;66.8.180.61;.;;;;;;2007-03-20 13:51:10;C;2007-04-05;0000-00-00\r\n";

//get the data retrieved from the curl and explode each transaction by '\r\n'
$transactions = explode("\r\n", $data);

//run each transaction
foreach ($transactions as $id => $transaction) {
	
    //assign incoming the exploded data which should be pointed to with the outgoing pointers allready created... 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();
}
?>
 [2007-05-17 09:58 UTC] tony2001@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 15:01:33 2024 UTC