help me...... string prob...strcat(): ?????????

A

Anonymous

Guest
:( ...


i have a var $watever1 ,$waterver2 and $watever3

i wanna make a loop on these var with a counter. like dat i wont have to retype the behavior each time. :wink: ..(lazy guy)

is there any strcat($waterver, $counter); ???
like in the lib <string.h> in C ??????

$counter ll be like $counter ++ at each loop....

:oops:

hope its clear....

bye
thx all 4 ur help







 
Code:
$tempassign = '$localvar = $whatever' . $counter . ';';
eval($tempassign);

if you do this at the start of the loop $localvar will have the value of each of the variables you want to walk through.
"eval" simply executes the code it gets. (http://www.php.net/eval)

you can do the same at the end of the loop to place some value back in the variable to actualy change it.

although it might be nicer to put those variables in an array when those variables ($whatever1, $whatever2) are created. (if that is possible ofcourse).
 
Back
Top