Page 1 of 1

How to create table rows data from a tokenized value

Posted: Thu May 13, 2004 2:27 am
by santdas
Hi All,

I have one value as:

$searchVal = "e:\\shared\\Alihaider-purani jeans.mp3||AliHaider - Purani Jeans@@e:\\shared\\KantaLaga.mp3||DJ Doll - Kanta Laga@@" ;

How can I create a table from this value in following way:
(Each table row data is separated by "@@" and the displayed TD data is the second token in every row value, separated by"||")

<TABLE>

<TR>
<TD vAlign=center align=left bgColor=#2e2e2e height=30>
<input type='hidden' name='row1' value='e:\\shared\\Alihaider-purani jeans.mp3||AliHaider - Purani Jeans'>
AliHaider - Purani Jeans
</TD>
</TR>


<TR>
<TD vAlign=center align=left bgColor=#2e2e2e height=30>
<input type='hidden' name='row1' value='e:\\shared\\KantaLaga.mp3||DJ Doll - Kanta Laga'>
DJ Doll - Kanta Laga
</TD>
</TR>

</TABLE>


Please help me. Its very urgent.

Thanks in advance.

Posted: Thu May 13, 2004 3:44 am
by feyd

Code: Select all

<table>
<?php
$searchvar = "e:\\shared\\Alihaider-purani jeans.mp3||AliHaider - Purani Jeans@@e:\\shared\\KantaLaga.mp3||DJ Doll - Kanta Laga@@";
$songs = explode("@@",$searchvar);

foreach($songs as $k => $song)
{
  if(empty($song))
    continue;
  list($file,$name) = explode("||",$song);
  echo<<<EOD
<tr>
<td vAlign=center align=left bgColor=#2e2e2e height=30><input type='hidden' name='row$k' value='$song'>$name</td>
</tr>
EOD;
}
?>
</table>
[edit:oops. mistyped empty()]

Posted: Thu May 13, 2004 4:48 am
by santdas
oh, it worked. Thanks a lot feyd!!