Getting '&' from any decoding function or any method?

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

Post Reply
jishcem
Forum Newbie
Posts: 12
Joined: Tue Nov 10, 2009 11:48 pm

Getting '&' from any decoding function or any method?

Post by jishcem »

Hi guys,
I want to get the value '&' (amphersand). The only one condition is that it should not use another '&' (amphersand) to create it. I know html_entity_decode() can be used to it, but it uses the string value & in it. Any ideas?
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Getting '&' from any decoding function or any method?

Post by internet-solution »

jishcem
Forum Newbie
Posts: 12
Joined: Tue Nov 10, 2009 11:48 pm

Re: Getting '&' from any decoding function or any method?

Post by jishcem »

Thanks :)
internet-solution
Forum Contributor
Posts: 220
Joined: Thu May 27, 2010 6:27 am
Location: UK

Re: Getting '&' from any decoding function or any method?

Post by internet-solution »

Is this for a school assignment?
jishcem
Forum Newbie
Posts: 12
Joined: Tue Nov 10, 2009 11:48 pm

Re: Getting '&' from any decoding function or any method?

Post by jishcem »

Actually, no. It is not. I was trying to hack some CSS, I mean putting some high width and high div. And for that I need to replace the Amphersand value in the string. html_entity_code is useful, so I used to display the < and > sign, but it was done, then the issue was with & (Amphersand), Then I got your answer, After this only one problem left, that is replacing the value of the php 's starting code,( < is < so, in the if I put <, it will again replace & with & ) it cannot be done, I think,
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Getting '&' from any decoding function or any method?

Post by AbraCadaver »

Examples would help, but in general some simple regexes will do it. To replace an & but not & something like this:

Code: Select all

$new = preg_replace('/&(?!amp;)/i', $replacement, $old);
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply