Setting an array element to a variable

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sabastious
Forum Newbie
Posts: 8
Joined: Thu Jul 20, 2006 6:09 pm

Setting an array element to a variable

Post 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?
GM
Forum Contributor
Posts: 365
Joined: Wed Apr 26, 2006 4:19 am
Location: Italy

Post 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];
sabastious
Forum Newbie
Posts: 8
Joined: Thu Jul 20, 2006 6:09 pm

Post by sabastious »

sigh, dont I feel sheepish.
Post Reply