while($variable) { echo 'string array'; }
How to add the last string in the last line in the loop for example?
while($variable) { echo 'string array'; }
How to add the last string in the last line in the loop for example?
one)
$variable = array('str1','str2','str3'); for($i=0;$i<count($variable)-1;i++){ echo $variable[$i]; } $i++; echo 'Last String:'.$variable[$i];//Если фраза идет после строки, вообще мудрить ничего не надо
2)
$variable = array('str1','str2','str3'); $last = array_pop($variable); while($str = array_shift($variable)) { echo $str; } echo 'Last String:'.$last;//Если фраза идет после строки, вообще мудрить ничего не надо
while(!последняя_строка){ echo $очередная строка; } echo 'last string'.$последняя_строка;
In general, it all depends on the context.
make a thread increment variable and then print the last line.
Source: https://ru.stackoverflow.com/questions/57557/
All Articles