Saturday, 15 May 2010

php - Get the last for loop variable value -



php - Get the last for loop variable value -

i want display lastly modified variable outside loop

code:

for( $i = 1; $i <= 100; $i++ ) { $pm_discussion = $_post['pm_discussion'.$i]; $pm_update = $_post['pm_update'.$i]; $pm_reports = $_post['pm_reports'.$i]; $pm_informed = $_post['pm_informed'.$i]; $pm_complete = $_post['pm_complete'.$i]; } **echo $pm_discussion;**

for example:

$i within loop having values 1 6.

then should display $pm_discussion = $_post['pm_discussion'.$i];

the above $i should 6.

try next code.

$temp=''; for( $i = 1; $i <= 100; $i++ ) { $pm_discussion = $_post['pm_discussion'.$i]; $pm_update = $_post['pm_update'.$i]; $pm_reports = $_post['pm_reports'.$i]; $pm_informed = $_post['pm_informed'.$i]; $pm_complete = $_post['pm_complete'.$i]; if($pm_discussion!='') $temp = $pm_discussion; } echo $temp;

php

No comments:

Post a Comment