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
Bigun
Forum Contributor
Posts: 237 Joined: Tue Jun 13, 2006 10:50 am
Post
by Bigun » Fri Jun 23, 2006 9:01 pm
I'm trying to check the values for $songname0 through 9 and same for $songfile.
The code below is the best I could come up with. But alas, it just reads the values of $i.
Code: Select all
for($i = 0; $i < 10; $i++) {
if ($songfile.$i != "" && $songname.$i != "") {
//Song Present - Run Tests
echo $songfile.$i."<br>";
echo $songname.$i."<br>";
echo "Slot ".$i." contains valid data<br>";
}
}
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Fri Jun 23, 2006 9:13 pm
use intermediate variable to construct the variable name you need:
Code: Select all
//.......
$currsongfile = 'songfile' . $i;
echo $$currsongfile;
//.......
Bigun
Forum Contributor
Posts: 237 Joined: Tue Jun 13, 2006 10:50 am
Post
by Bigun » Fri Jun 23, 2006 9:17 pm
Weirdan wrote: use intermediate variable to construct the variable name you need:
Code: Select all
//.......
$currsongfile = 'songfile' . $i;
echo $$currsongfile;
//.......
What does the extra $ do?
Weirdan
Moderator
Posts: 5978 Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine
Post
by Weirdan » Fri Jun 23, 2006 9:22 pm