Friday, 15 January 2010

php - How can I store for loop in a variable? -



php - How can I store for loop in a variable? -

how can store in $_var variable ?

$s_number = 5; $spn = '6'; echo "'landscapes':["; ($i = 1; $i <= $s_number; $i++) { echo "'".$spn."/"."content"."/".$i.".png"."'".", "; } echo "]";

question bit vague though seems looking this,

$string = "'landscapes':["; ($i = 1; $i <= $s_number; $i++) { $string .= "'".$spn."/"."content"."/".$i.".png"."'".", "; } $string .= "]"; echo $string;

php variables for-loop

No comments:

Post a Comment