Re: Variables

From: "Areski Belaid" <areski5(at)hotmail(dot)com>
To: <pgsql-php(at)postgresql(dot)org>, "Julio Cuz, Jr(dot)" <jcuz(at)rccd(dot)cc(dot)ca(dot)us>
Subject: Re: Variables
Date: 2002-04-25 17:18:06
Message-ID: OE35cxDRIME72AC1kox00001229@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hi the Community,

A good exemple, it's always better that a long...
You must use the eval fonction. (www.php.net)

<?
$artist[]="Areski1";
$artist[]="Areski2";
$artist[]="Areski3";
$artist[]="Areski4";

$c0="Kiki1";
$c1="Kiki2";
$c2="Kiki3";
$c3="Kiki4";

for($count = 0; $count < sizeof($artist); $count++)
{
eval( "echo \$c$count.\"<br>\";" ); //just to see no important
eval( "\$c$count = \"$artist[$count]\";" );
eval( "echo \"-->\".\$c$count.\"<br><br>\";" );//just to see no important
}
?>

I have the following variables: $c1 thru $c10.
a.. I also have a FOR loop like this:
for($count = 0; $count < sizeof($artist); $count++)
{ echo "<i>$artist[$count]</i><br>"; }
// $artist is a list of ten (10) artist's names.
a.. What I'm trying to do is something like this: Combine the variables with the info inside the FOR loop:
for($count = 0; $count < sizeof($artist); $count++)
{ //Trying to assign the value of $c1, $c2, $c3, etc. using the value of the variable $count.
//But so far, it only processes the value of $count alone, and it ignores $c
//The line below should read like this: $c1 = $artist[0], next line: $c2 = $artist[1], etc.
$c . $count+1 = $artist[$count];
}

Help!!!
Julio Cuz, Jr.
Riverside Community College
jcuz(at)rccd(dot)cc(dot)ca(dot)us

In response to

  • Variables at 2002-04-25 15:57:31 from Julio Cuz, Jr.

Browse pgsql-php by date

  From Date Subject
Next Message Kwabena Adowah Adu 2002-04-25 17:56:33 Re: Variables
Previous Message Papp, Gyozo 2002-04-25 16:07:13 Re: printer friendly version