Jump to content
php.lv forumi

curl + preg_replace


SkaKri

Recommended Posts

kods:

<?php
function bbcode_format ($str) {


	$simple_search = array( 
							'/\n|(\r\n)/m',
							'/\[b\](.*?)\[\/b\]/is',								
							'/\[i\](.*?)\[\/i\]/is',								
							'/\[u\](.*?)\[\/u\]/is',
							'/\[small\](.*?)\[\/small\]/is',
							'/\[url\=(.*?)\](.*?)\[\/url\]/is'
							);

	$simple_replace = array(
							'<br />',
							'<b>$1</b>',
							'<i>$1</i>',
							'<u>$1</u>',
							'<small>$1</small>',
							'<a href="$1" target="_blank">$2</a>'
							);

	// Do simple BBCode's
	$str = preg_replace ($simple_search, $simple_replace, $str);

	return $str;
}
$ch = curl_init("http://www.shoutcast.com/directory/?s=skvotsnet");
$fp = fopen("data.txt", "w");

curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);

curl_exec($ch);
curl_close($ch);
fclose($fp);
?>

 

http://www.skvots.net/data.txt - kā lai novācu visu lieko - tā lai paliek

<a id="listlinks" target="_scurl" href="http://www.skvots.net">SKVOTSnet radio (beta)</a><br>
<font size="1"><font color="#FF0000">Now Playing:</font> Pg99 - The Longer Now</font></font></td>
  <td nowrap align="center" width="10" bgcolor="#001E5A"> </td>
  <td nowrap align="center" bgcolor="#001E5A"><font face="Arial, Helvetica" size="2" color="#FFFFFF">1/20</font></td>
  <td nowrap align="center" width="10" bgcolor="#001E5A"> </td>
  <td nowrap align="center" bgcolor="#001E5A"><font face="Arial, Helvetica" size="2" color="#FFFFFF">96</font></td>
  <td nowrap align="center" width="10" bgcolor="#001E5A"> </td>

?

+ lai novāktu arī

<td nowrap align="center" width="10" bgcolor="#001E5A"> </td>

un <font> tagus? to f-ciju, jau kkā tak var ievietot? tikai, kur jāliek "\" - tur tā problēma.

Link to comment
Share on other sites

principā ieraksti visu to ko tu gribi redzeet ieksh preg_match, un pasaki lai atdod mainiigajaa, un tad nogriez nost visu lieko ar preg_match, tur nevajag preg_replace :)

 

a ja tev jānovāc statiskais tags, ar domu ka kraasa nemainaas utt, tad lieto str_replace(); viņam nevajag slashus likt :) viņš bez tā apietas normāli :)

Edited by [Ya]
Link to comment
Share on other sites

' date='2006. gada 14. Jun 12:30' post='39297']strip_targ($atbilde,"<a>");

function strips ($str) {
	$nahrenizeet = array(
							'<a>',
							'</a>'
							);

	$str = strip_targ($str, $nahrenizeet);

	return $str;
}

tā?

Link to comment
Share on other sites

×
×
  • Create New...