kernelgpf Posted January 2, 2007 Share Posted January 2, 2007 [code]$space='$row[space';$space.="$i]";$space="$space";$spacepic='$row[space';$spacepic.="$i";$spacepic.='pic]';$spacepic="$spacepic";[/code]Basically, this code is running in a for loop, and $i is the incremented number.. the possible variables are space1, space2, space3, etc. etc. up until 9, and I've got it to add the $i in, but now when I ask it to print, it's printing the variable name, not the value, because I had to put single quotes around the $i else it would cause a parse error. Link to comment https://forums.phpfreaks.com/topic/32612-print-value-of-variable-not-variable-name/ Share on other sites More sharing options...
trq Posted January 2, 2007 Share Posted January 2, 2007 Sorry, but that code makes no sense. Post your loop and maybe we can see what your trying to do. Link to comment https://forums.phpfreaks.com/topic/32612-print-value-of-variable-not-variable-name/#findComment-151688 Share on other sites More sharing options...
sasa Posted January 2, 2007 Share Posted January 2, 2007 try[code]<?php$row=array('space1'=>11,'space2'=>12,'space1pic'=>21,'space2pic'=>22);for ($i=1;$i<3;$i++) { $a = 'space'.$i; echo $row[$a]; echo "<br />\n"; // or echo $row['space'.$i.'pic']; echo "<br />\n";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/32612-print-value-of-variable-not-variable-name/#findComment-151692 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.