PHP Classes

Breaking W3C Validity

Recommend this page to a friend!

      Syron Twitter  >  All threads  >  Breaking W3C Validity  >  (Un) Subscribe thread alerts  
Subject:Breaking W3C Validity
Summary:improving twitter class so that does convert & to &
Messages:2
Author:Paul Bakulich
Date:2011-03-11 01:16:22
Update:2011-03-11 03:39:06
 

  1. Breaking W3C Validity   Reply   Report abuse  
Picture of Paul Bakulich Paul Bakulich - 2011-03-11 01:16:22
Hi, could you improve this class so that it doesn't break W3C standards.

I have only noticed "&" doesn't get converted to "&"

I'm gonna try converting the imported XML - so that it transforms "&" to "&"

Thanks
Paul

  2. Re: Breaking W3C Validity   Reply   Report abuse  
Picture of Paul Bakulich Paul Bakulich - 2011-03-11 03:39:07 - In reply to message 1 from Paul Bakulich
I put together this new function:

I called it in function readPosts()
with: $description = $this->convertAmpersand($description);

function convertAmpersand($description) {
$arr = explode(' ', $description);
echo count($arr);
foreach ($arr as $word) {
$wArr = str_split($word);
foreach ($wArr as $char) {
if ($char === "&") {
echo "&";
}
else {
echo $char;
}
}
echo ' ';
}
}
Seems to work well - maybe it might be done better by using a htmlentities / something to convert each char to HTML.

Paul