我的代码中有一个for循环:
$d = count( $v2['field_titles'] );
for( $i=0; $i < $d; $i++ ) {
$current = 3 + $i;
echo 'current is' . $current;
}
Run Code Online (Sandbox Code Playgroud)
如果我不知道 的确切数量,我如何知道最后一次迭代$d?
我想做类似的事情:
$d = count( $v2['field_titles'] );
for( $i=0; $i < $d; $i++ ) {
$current = 3 + $i;
if( this is the last iteration ) {
echo 'current is ' . $current;
// add sth special to the output
}
else {
echo 'current is ' . $current;
}
}
Run Code Online (Sandbox Code Playgroud)