dsaba Posted March 9, 2007 Share Posted March 9, 2007 i usually explain the crap out of what i need help in in the hopes that it will better assist those who try to help me, but I'll keep it simple this time, since i seem to confuse people, and overload them with information I want to write an array called $pattern, that has these things in it: < > / \ " ' ` i tried this: $pattern[0] = "<"; $pattern[1] = ">"; $pattern[2] = "/"; $pattern[3] = "\"; $pattern[4] = "'"; $pattern[5] = """; $pattern[6] = "`"; that does not work, i'm NOT writing it correctly I KNOW that can someone show me the CORRECT way to write this? thank u Link to comment https://forums.phpfreaks.com/topic/42055-array-syntax/ Share on other sites More sharing options...
fert Posted March 9, 2007 Share Posted March 9, 2007 $pattern[0] = "<"; $pattern[1] = ">"; $pattern[2] = "/"; $pattern[3] = "\\"; $pattern[4] = "'"; $pattern[5] = "\""; $pattern[6] = "`"; Link to comment https://forums.phpfreaks.com/topic/42055-array-syntax/#findComment-203953 Share on other sites More sharing options...
kenrbnsn Posted March 9, 2007 Share Posted March 9, 2007 You need to either enclose the double quote in single quotes or escape the double quote. Either of these statements will work: <?php $pattern[5] = '"'; $pattern[5] = "\""; ?> Ken Link to comment https://forums.phpfreaks.com/topic/42055-array-syntax/#findComment-203955 Share on other sites More sharing options...
Glyde Posted March 9, 2007 Share Posted March 9, 2007 Ken, he also must escape the backslash as shown in the second post. Link to comment https://forums.phpfreaks.com/topic/42055-array-syntax/#findComment-203956 Share on other sites More sharing options...
dsaba Posted March 9, 2007 Author Share Posted March 9, 2007 i'm using this array in this script: $pattern[0] = "<"; $pattern[1] = ">"; $pattern[2] = "/"; $pattern[3] = "\\"; $pattern[4] = "'"; $pattern[5] = "\""; $pattern[6] = "`"; $string = "A 'quote' is <b>bold</b>"; echo "BEFORE-"; echo $string; $string = html_entity_decode($string); $string = preg_replace($pattern, "", $string); echo "AFTER-"; echo $string; // i want the after too look like this: A quote is bold its not working, give me these errors: BEFORE-A 'quote' is <b>bold</b> Warning: preg_replace(): No ending matching delimiter '>' found in /home/www/p2mhunt.awardspace.com/eot.php on line 30 Warning: preg_replace(): No ending delimiter '>' found in /home/www/p2mhunt.awardspace.com/eot.php on line 30 Warning: preg_replace(): No ending delimiter '/' found in /home/www/p2mhunt.awardspace.com/eot.php on line 30 Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /home/www/p2mhunt.awardspace.com/eot.php on line 30 Warning: preg_replace(): No ending delimiter ''' found in /home/www/p2mhunt.awardspace.com/eot.php on line 30 Warning: preg_replace(): No ending delimiter '"' found in /home/www/p2mhunt.awardspace.com/eot.php on line 30 Warning: preg_replace(): No ending delimiter '`' found in /home/www/p2mhunt.awardspace.com/eot.php on line 30 AFTER-A 'quote' is bold</b> I don't really understand what the errors mean, but I want to make my script "do" what its supposed to do 1. first html decode 2. then remove those characters can u tell me how to make it "work" with this code, or new code that will make it "work" -thanks Link to comment https://forums.phpfreaks.com/topic/42055-array-syntax/#findComment-203962 Share on other sites More sharing options...
fert Posted March 10, 2007 Share Posted March 10, 2007 use str_replace instead of preg_replace Link to comment https://forums.phpfreaks.com/topic/42055-array-syntax/#findComment-203993 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.