PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
raymedia
Forum Commoner
Posts: 27 Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia
Post
by raymedia » Wed Oct 06, 2004 6:13 am
hi guys,
this is my code
Code: Select all
$str = '<TD class="clsNormal">(03) 9391 4572.</TD>';
$strNoHTML= preg_split('((>)|(<))', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
print_r($strNoHTML);
//display: 'Array ( ї0] => <TD class="clsNormal">(03) 9391 4572.</TD> ) '
So, why its not removing the html tags? Any help will be great
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Oct 06, 2004 6:21 am
you don't have a beginning and ending delimiter:
Code: Select all
$str = '<TD class="clsNormal">(03) 9391 4572.</TD>';
$strNoHTML= preg_split('#(>|<)#', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
print_r($strNoHTML);
//display: 'Array ( [0] => <TD class="clsNormal">(03) 9391 4572.</TD> ) '
raymedia
Forum Commoner
Posts: 27 Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia
Post
by raymedia » Wed Oct 06, 2004 6:34 am
thanks feyd..but its not working. this is my full code
Code: Select all
function getSchoolInfo(){
$lines = file('http://www.eduweb.vic.gov.au/SchoolsOnline/Details.asp?LocationID=01493101');
$schoolPhone = htmlspecialchars($linesї81]);
print_r(remHTML($schoolPhone));
}
function remHTML($str){
$strNoHTML= preg_split('#(>|<)#', $str, -1, PREG_SPLIT_DELIM_CAPTURE);
return $strNoHTML;
}
twigletmac
Her Royal Site Adminness
Posts: 5371 Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK
Post
by twigletmac » Wed Oct 06, 2004 7:09 am
It would be a good idea to do htmlspecialchars() after the regex - remember that < and > will get converted to their entity equivelants using that function...
(look at the source of your generated page)
Mac
raymedia
Forum Commoner
Posts: 27 Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia
Post
by raymedia » Wed Oct 06, 2004 7:12 am
Great..its working now... thanks for your help.. have a great day