Page 1 of 1
Getting '&' from any decoding function or any method?
Posted: Tue Jun 22, 2010 5:14 am
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?
Re: Getting '&' from any decoding function or any method?
Posted: Tue Jun 22, 2010 6:26 am
by internet-solution
Re: Getting '&' from any decoding function or any method?
Posted: Tue Jun 22, 2010 6:33 am
by jishcem
Thanks

Re: Getting '&' from any decoding function or any method?
Posted: Tue Jun 22, 2010 6:48 am
by internet-solution
Is this for a school assignment?
Re: Getting '&' from any decoding function or any method?
Posted: Tue Jun 22, 2010 6:57 am
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,
Re: Getting '&' from any decoding function or any method?
Posted: Tue Jun 22, 2010 12:39 pm
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);