0

I don't know if this question has been already asked! It really seems to be new! I found something similar here, but it is for Java, not PHP.

Here follows my problem. On the client-side, I'm using TinyMCE to get a long text. On the server-side, I extract the first n words from that string for listing purpose.

In particular, the string returned contains HTML code, that I remove by using the PHP strip_tags() function, and it also contains ASCII characters (e.g.   for spaces).

Is there any PHP function that automatically convert all the ASCII contained in a string or capable to detect all the ASCII code in a string?

In the first case all would be easy; in the latter I should find the ASCII and then replace it with the chr() function.

1 Answer 1

1

Check the function html_entity_decode()

From the documentation :

html_entity_decode() is the opposite of htmlentities() in that it converts all HTML entities in the string to their applicable characters.

Sign up to request clarification or add additional context in comments.

3 Comments

Does it returns a string with "-" as separator?
Why would it? It replaces html centities to the corresponding character.   becomes a space, & becomes &, etc.
Sorry! My question was related to this accepted answer. The author shown that the result was the string with the words separated by "-". Thanks! Your answer will be accepted!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.