[wd_asp elements=’search’ ratio=’100%’ id=1]

Dynamic variable iteration – change var on fly

4th July 2014

Php - Loops

php codehaven

This starts by adding first result to client1 then adds to client2 and client3. The variable name is changing easch time due to count set on $m.
The variable name is set using braces ${client.$m}

while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$m=$i+1;
${client.$m} = $row['client'];
${client.$m.camp} = stripslashes($row['campaign']);
$i++;
}