So if $camp['pozitie']
has a specific value and $camp['cod_garantie']
is empty, you have to alter all the following positions, correct?
You can add a counter and add it to the position key, here's an example:
<?php
$datum[] = array('name' => 'sun', 'pos' => 1, 'magnitude' => '-26.74');
$datum[] = array('name' => 'venus', 'pos' => 2, 'magnitude' => '-5');
$datum[] = array('name' => 'sedna', 'pos' => 3, 'magnitude' => '');
$datum[] = array('name' => 'neptune', 'pos' => 4, 'magnitude' => '8');
$datum[] = array('name' => 'io', 'pos' => 5, 'magnitude' => '');
$datum[] = array('name' => 'moon', 'pos' => 6, 'magnitude' => '-12.74');
echo PHP_EOL;
$i = 0;
foreach($datum as $key => $value)
{
if(empty($value['magnitude']))
{
$i++;
}
if($i > 0) $value['pos'] = $value['pos'] + $i;
echo "\t" . $value['pos'] . ' ' . $value['name'] ."\t" . $value['magnitude'] . PHP_EOL;
}
echo PHP_EOL;
will output:
1 sun -26.74
2 venus -5
4 sedna
5 neptune 8
7 io
8 moon -12.74
Note rows 4 and 7, the original values are 3 and 5.