I got a question that hopefully is easy to answer.
In the function below the part "foreach($daten as $row)" is ignored in the second turn. Can somebody tell me, why the function acts that way?
I already tried to delete the "break"... no success.
function verweis_show($string,$art,$daten){
$ausgang = preg_split("/\[-\[(.*?)\/(.*?)\/(.*?)\]-\]/", $string,0,PREG_SPLIT_DELIM_CAPTURE);
$n = 0;
foreach($ausgang as $teil)
{
$n++;
if($n == 1)
{
$ergebnis .= $teil;
}
elseif($n == 2)
{
$stat_id = $teil;
}
elseif($n == 3)
{
$rel_id = $teil;
if ($art != "old")
{
$z = 0;
// wird im zweiten durchlauf seltsamerweise nicht noch einmal durchlaufen
foreach($daten as $row)
{
$z++;
if ($row['id'] == $stat_id)
{
$rel_id = $z;
break;
}
}
}
}
elseif($n == 4)
{
$ergebnis .= "<div contenteditable='false' id='text_$stat_id' class='$teil' tabindex='-1'>$rel_id</div>";
$n = 0;
}
}
return $ergebnis;
}