I'm having an issue finding a solution here.. I'm developing a WordPress theme for a client that uses a for()
loop to iterate through the title of the page so it can be wrapped in <span>
s and displayed vertically.. the loop uses strlen()
to find the length of the title but since some of the page titles include '...' or commas in the title it returns the html chars instead.. I can't figure out what is causing that and every effort via htmlspecialchars_decode()
or html_entity_decode()
doesn't work.. any suggestions? Is there something going on with the for loop that I'm now aware of?
Since it was requested here is the actual code:
$p_title = get_the_title($port_page->ID);
$title = '';
for($i=0;$i<strlen($p_title);$i++){
if(($p_title[$i])){
$title .="<span>$p_title[$i]</span>";
}
I've tried using mb_strlen as well.. the problem with searching for a specific character to replace doesn't necessarily solve the problem since page titles are arbitrarily set by the site owner..
The weird thing is the Title is not encoded in any way and echo's normally before the for loop.. So it's as if something is converting it..