Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

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

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

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







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

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


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.