Answers for "how to get a variable outside the foreach loop"

0

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]; ?>" />
Posted by: Guest on October-19-2020

Code answers related to "how to get a variable outside the foreach loop"

Browse Popular Code Answers by Language