access to foreach variable outside foreach code example
Example: how to get a variable outside the foreach loop
$date_array = array();
if( !empty($row_edit) ){
$stageDates = explode(', ',$row_edit['placement_stage_date']);
foreach( $stageDates as $stageDate ){
//echo $stageDate.'<br/>';
$date_array[] = $stageDate;
}
}
// print $stageDate value outside of loop, something like this
<input type="text" name="placement_stage_date[]" value="<?php echo $date_array[0]; ?>" />
<input type="text" name="placement_stage_date[]" value="<?php echo $date_array[1]; ?>" />
<input type="text" name="placement_stage_date[]" value="<?php echo $date_array[2]; ?>" />