I have a table containing several groups of numbers such
3 4 5 6 7 8 9 15 16 17 18 19 20 52 53 54 55 56 57 58
I get the first and last element of each group of numbers in a new table. In my example, I therefore in my new table 3 9 15 20 52 58
That is what I wrote but it does not work.
PHP Code:
$tab1 = array ();
$i = 1;
$j = 0;
$debut1 = current ($tab); // first element of my first table
$val = $debut1;
$val2 = $val + $i;
foreach ($tab as $value)
{
$val2 = $val + $i;
$val3 = next ($ tab);
if ($val3 = $val2)
{
$i++;
$tab1 [ $j ] = $val;
}
else
{
$j++;
$tab1 [ $j ] =prev ( $tab );
$val = current ($tab);
}
}
Bookmarks