Page 1 of 1

Setting an array element to a variable

Posted: Wed Jul 26, 2006 10:22 am
by sabastious
When I run this code:

Code: Select all

$arrResponse = explode("&", $response);
 
 $products = $arrReponse[0];
 $avail = $arrReponse[1];
 $billtype = $arrReponse[2];
 $phone = $arrReponse[3];
 
 echo $response . "<BR><BR>";
 echo $prodcuts . "<BR>";
 echo $avail . "<BR>";
 echo $billtype . "<BR>";
 echo $phone . "<BR>";
the varibles that I am trying to put values to are not getting set. If I echo $arrResponse[0] it writes fine. But if I echo $response it writes nothing. Is this the wrong syntax to give these variables array element values?

Posted: Wed Jul 26, 2006 10:24 am
by GM
Not sure whether this is the problem, but you are missing an "s" in your array variables:

Code: Select all

$arrResponse = explode("&", $response); 
  
 $products = $arrReponse[0]; // should be $arrResponse[0]
 $avail = $arrReponse[1]; 
 $billtype = $arrReponse[2]; 
 $phone = $arrReponse[3];

Posted: Wed Jul 26, 2006 10:29 am
by sabastious
sigh, dont I feel sheepish.