Generating ul from array with php fails

Posted by Toni Michel Caubet on Stack Overflow See other posts from Stack Overflow or by Toni Michel Caubet
Published on 2012-11-02T10:58:10Z Indexed on 2012/11/02 11:00 UTC
Read the original article Hit count: 202

Filed under:
|
|
|

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="&lt;a class=" class="add_to_files">http://domain.com/files/uploads/388400967232883.jpg"&gt;Agregar al gestor</span>
    </li>
</ul>

Any idea why?

© Stack Overflow or respective owner

Related posts about php

Related posts about html