I need an HTML-safe function which will change a first letter of the content to the image source.
So if my content will be: "Hello World!” the output will look like:
"<img src="/images/letters/H.png" alt="H"/>ello"
I’ve tried something like:
$content = '<img src="/images/letters/'.$content[0].'.png" />'.substr($content, 1);
But I’ve heard this way isn’t safe for HTML due to characters like < and >.
will work just fine, it will always be truncated to 1 character, so as long as you have no sensitive files in that directory named _.png or something, you’re fine. To ensure your page doesn’t break: