Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php foreach loop first element

$i = 0;
$len = count($array);
foreach ($array as $item) {
    if ($i == 0) {
        // first
    } else if ($i == $len - 1) {
        // last
    }
    // …
    $i++;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #foreach #loop #element
ADD COMMENT
Topic
Name
7+2 =