Jump to content

array syntax


dsaba

Recommended Posts

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

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&gt";
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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.