Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199903

RE: [PHP3] Array Question From: Graeme Merrall (graeme <email protected>)
Date: 03/31/99

> Okay...how do I do this:
>
> $a=1;
> $b="c";
> $c="g8dh";
>
> I want to send these variables (only more) to a class to be
> processed. but I
> want to send them as an array and then break them out and be able to
> recognize the key,value pairs. I know that I can implode them,
> put them into
> the array, and explode them from the array. But then how do I keep the
> variable names?
>
There's prob a waaay better way to do this...
Not sure how you'd dynamically load the array though. I kinda invented this
so if there is a better way I'm all ears. Always learning...

$array[] = array("var"=>"a", "value"=>1);
$array[] = array("var"=>"b", "value"=>"c");
$array[] = array("var"=>"c", "value"=>"g8dh");

//Then pass the array be reference &$array

//then slurp it out again...
while (list($tmp,$tmparray) = each($array)) {
  // $tmp is the array number
  ${$tmparray["var"]} = $tmparray["value"];
}

echo $c;

Cheers,
 Graeme

--
PHP 3 Mailing List   http://www.php.net/
To unsubscribe send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest list:  php3-digest-subscribe <email protected>
For help: php3-help <email protected>  Archive:  http://www.php.net/mailsearch.php3
List administrator:  zeev-list-admin <email protected>