Generating ul from array with php fails
- by Toni Michel Caubet
Given a $files array I am trying to generate a list, like this:
<ul class="">
    <?
    for($i=0;$i < count($files); $i++) {
        $text = str_replace("http://domain.com/files/uploads/", "", $files[$i]);
        $file = $files[$i];
        $notme = sesion()>0 && $obj['id'] != sesion();
        ?>
        <li> <a target="_blank" href="<?=$file?>"><?=$text?></a> 
        <?  if($notme){ ?>
        <span class="add_to_files" data-file="<?=$file?>">Agregar al gestor</span>
        <?  }   ?>
        </li>
        <?
    } 
?>  </ul> 
This is the output: Please note how the span html is wrong, 
<ul class="">
    <li> <a href="http://domain.com/files/uploads/388400967232883.jpg" target="_blank">388400967232883.jpg</a>  
         <span target="_blank" href="http://domain.com/files/uploads/388400967232883.jpg" url"="" data-file="<a class=" class="add_to_files">http://domain.com/files/uploads/388400967232883.jpg">Agregar al gestor</span>
    </li>
</ul>
Any idea why?