Question: I have an array of objects, any array in php.
How do i skip the last element in the foreach iteration?

Answer: 
There's various ways to do this.

If your array is a sequentially zero-indexed array, you could do:

```
for( $i = 0, $ilen = count( $array ) - 1; $i < $ilen; $i++ )
{
    $value = $array[ $i ];

    /* do something with $value */
}

```

If your array is an associative array, or otherwise not sequentially zero-indexed, you could do:

```
$i = 0;
$ilen = count( $array );
foreach( $array as $key => $value )
{
    if( ++$i == $ilen ) break;

    /* do something with $value */
}

```
```
$count = count($array);
$i=0;
foreach ($arr as &$value) 
{
    $i++;
    if($i==($count-1))
    {
      echo 'skip';
    }
    else
    {
      echo $value;
    }
}

```