<?PHP$get_news_info_post_text = "Here are some fun new products by apple.[url]http://www.apple.com/macmini/[/url]These people.[url=www.apple.com/macmini/]These People[/url]. This is a fun challenge. Good Site: [url]www.slashdot.org[/url]enjoy!";/////////////////////////////////////////////////////////////////////////////////////////////////////// Start string replacements /////////////////////////////////////////////////////////[url* Management/////////////////////////////////////////Count all occurences of "[url"$number_of_beg_url_tags = substr_count($get_news_info_post_text, '[url');//Explode Text by "[url"$string_pass_one = explode('[url', $get_news_info_post_text);//Perform following operations for each separated tagfor($i = 0; $i <= $number_of_beg_url_tags; $i++) { //No need to join anything if( $i == 0 ) { $compiled_string = "$string_pass_one[0]"; } if( $i >= 1) { //Separate link from extranneous text $string_pass_two = explode('[/url]', $string_pass_one[$i]); //Drop first character of string (left over from [url= or [url] $string_pass_two[0]=substr($string_pass_two[0],1); //Explode by the "]" if present $link = explode(']', $string_pass_two[0], 2); //If the url was of [url] format, set variable as it is currently unset if (!isset($link[1])) { $link[1] = $string_pass_two[0]; } //Ensure http:// is present in link $link[0] = ('http://'.str_replace('http://', '', $link[0])); //Compile string $compiled_string .= "<a href=\"$link[0]\">$link[1]</A>$string_pass_two[1]"; }}print nl2br( $compiled_string );?>