I have a string of html codes. Within this html code, i have a so called “html delimiter” which help to split the html code into smaller chunks.
The delimiter is in the format of
<br class="limit" />
The html code is as below
<p>To be A Premier in Global Distinction<br class="limit" />To be A Premier Polytechnic of Global Distinction <br class="limit" />We provide quality education and training to prepare students and adult learners for work and life, equipping them to be life-long learners <br class="limit" />We will harness our resources, expertise, creativity and innovation to support the development of business and industry.</p>
This is my php code
$htmlparts = explode("<br class='limit' />", $htmlcode);
echo $htmlparts [0];
echo $htmlparts [1];
echo $htmlparts [2];
By right $htmlparts [0] should return me
To be A Premier in Global Distinction, $htmlparts[1] should return me To be A Premier Polytechnic of Global Distinction and so on.
By it fails to split. Appreciate any expert advice. thanks!
Your html sample has
"limit", while you’re trying to explode'limit'– note the difference in quoting styles. Explode requires an EXACT match on the delimiter. Since you’re using different quotes, there’ll never be a match and therefore no explosion.