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

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

cho@
New php-forum User
New php-forum User
Posts: 39
Joined: Tue Aug 06, 2002 8:58 am
Location: UK

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

Postby cho@ » Fri Aug 09, 2002 2:25 am

:( ...


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








DoppyNL

Postby DoppyNL » Fri Aug 09, 2002 2:32 am

Code: Select all

$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).


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 3 guests