Using a variable within a variable.
Posted: Thu Oct 04, 2007 4:41 pm
scottayy | Please use
Just wondering how I get the $i to register in the variable name?
Thanks!
Chris
scottayy | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Rather simple problem...Code: Select all
$j1company = "Company1";
$j2company = "Company2";
$num_jobs = 2;
for($i=1; $i<$num_jobs+1; $i++) {
if ($j{$i}company != "") {
echo $j{$i}company;
}
}Thanks!
Chris
scottayy | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]