hi gurus, i have a string how can i retrieve the text http://img215.imageshack.us/img215/1886/cleard.jpg Thanks for the guide
Your code would be something like this: <?php $regex = ''; // REGEX HERE $string = 'some text... [img:304uninl]http://img215.imageshack.us/img215/1886/cleard.jpg[/img:304uninl] some text... '; preg_match($regex, $string, $matches); print_r($matches); PHP: Unfortunately, I do not understand regular expressions so someone will need to pick up where i left off.
i have run my code <?php $regex = '%\](^\[)+\[%'; // REGEX HERE $string = 'some text... [img:304uninl]http://img215.imageshack.us/img215/1886/cleard.jpg[/img:304uninl] some text... '; preg_match($regex, $string, $matches); print_r($matches); ?> PHP: return NULL
<?php $string = <<<STRING some text... [img:304uninl]http://img215.imageshack.us/img215/1886/cleard.jpg[/img:304uninl] some text... STRING; $text = explode("\n", $string); //the first text print($text[0]); //the second lot of text print($text[2]); ?> PHP:
$str = "[img:304uninl]http://img215.imageshack.us/img215/1886/cleard.jpg[/img:304uninl]"; $exp = explde("uninl]",$str); // explode the start point $pos = strpos($exp[1],"[/"); // position the end point $sub = substr($exp[1],0,$pos); // cut the link echo $sub; PHP: If there are more links on page then $str = "[img:304uninl]http://img215.imageshack.us/img215/1886/cleard.jpg[/img:304uninl]"; foreach(range(1,20) as $range) { // from,to array values $exp = explde("uninl]",$str); // explode the start points $pos = strpos($exp[$range],"[/"); // get position of end points $sub = substr($exp[$range],0,$pos); // cut the link echo $sub; echo "<br>"; } PHP: