Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have 2 strings, when I do var_dump() I see one string is 5 characters longer than the other one.

I guess this is because in the first string, the ' (quote) is seen as ' or ' (but I am not sure about this).

string(15) "i'm a bird" 
string(10) "i'm a bird" 

I want the first string to have 10 chars aswell.

I already tried htmlspecialchars(), htmlspecialchars() with ENT_QUOTES, htmlspecialchars() with ENT_NOQUOTES, utf8_decode(), utf8_encode(), ...

It still stays a string(15).

Someone knows how to do it?

EDIT: @ Mathieu Imbert: When I look at the page source, I see it like this:

string(15) "i'm a bird"

SOLUTION:

EDIT: Thanks PeeHaa !! You code @ http://codepad.viper-7.com/pvHCwH fixed it!

html_entity_decode($title, ENT_QUOTES); 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
372 views
Welcome To Ask or Share your Answers For Others

1 Answer

If you want the first string to be 10 chars aswell, you need to DECODE the encoded value in the string. Check html_entity_decode

The example you give would make the second string also larger then 10 chars.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...