Jump to content

Array duplicate first value


gvp16

Recommended Posts

Hi, I have a multidimentional array which looks like this :

 

array(2) { ["HOKIT100E-041"]=> array(3) { [0]=> string(26) "Honda Cr 125-250 2000-2001" [1]=> string(5) "89.99" [2]=> string(1) "1" } 
["WAFAXS"]=> array(3) { [0]=> string(27) "Wulf Flite-x Helmet - Green" [1]=> string(5) "65.94" [2]=> string(1) "1" } } 

 

howver when I do a foreach on it, the 1st array is being duplicated and I have no idea why :(

 

this is the code I have :

 

foreach($basketArray as $key => $value)
{
echo$nvpstr = $nvpstr ."<br/><br/>&L_PAYMENTREQUEST_0_NUMBER$q=".$key." 
        <br/>&L_PAYMENTREQUEST_0_NAME$q=".$value[0]." 
        <br/>&L_PAYMENTREQUEST_0_AMT$q=".$value[1]." 
        <br/>&L_PAYMENTREQUEST_0_QTY$q=".$value[2];
$q++;
}

 

this is what is output :

 

&L_PAYMENTREQUEST_0_NUMBER0=HOKIT100E-041

&L_PAYMENTREQUEST_0_NAME0=Honda Cr 125-250 2000-2001

&L_PAYMENTREQUEST_0_AMT0=89.99

&L_PAYMENTREQUEST_0_QTY0=1

 

&L_PAYMENTREQUEST_0_NUMBER0=HOKIT100E-041

&L_PAYMENTREQUEST_0_NAME0=Honda Cr 125-250 2000-2001

&L_PAYMENTREQUEST_0_AMT0=89.99

&L_PAYMENTREQUEST_0_QTY0=1

 

&L_PAYMENTREQUEST_0_NUMBER1=WAFAXS

&L_PAYMENTREQUEST_0_NAME1=Wulf Flite-x Helmet - Green

&L_PAYMENTREQUEST_0_AMT1=65.94

&L_PAYMENTREQUEST_0_QTY1=1

 

Have I made a schoolboy error?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/258586-array-duplicate-first-value/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.