View Single Post
Old 03-24-2012, 12:52 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,638
Quote:
Originally Posted by Colmike7 View Post
Hey

How could I change a CSV and output to another CSV with html?

For example, if I have a csv in this form:
URL|Title|img|descr

But I want to output it like this:
<a href="[URL]" title="[Title]><img src="[img]" /> | [descr]

How could I do this without typing something custom in Java or anything like that?

Thanks
could do it via php

example links.txt

Code:
http://www.google.com|google|http://i.imgur.com/uwti0.jpg|google search engine
php

Code:
<?

$linkfile = dirname(__FILE__). "/links.txt";
$links = file($linkfile);
$result = array();

for ($i=0; $i<count($links); $i++) {
  $link = explode("|", $links[$i]);
  $result[] = '<a href="' . $link[0] . ' title="' . $link[1] . '"><img src="'.$link[2].'"></a> <span>'.trim($link[3]).'</span>';
  echo $result[$i];
}

?>
final output

Code:
[fris@fris ~]$ php test.php
<a href="http://www.google.com title="google"><img src="http://i.imgur.com/uwti0.jpg"></a> <span>google search engine</span>
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


Free Templates
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote