Cakephp Classroom image

Anil  Bist / Professional / Web Technology
 
To post your Question Join Classroom
 
Question No  (1 of 17)
 1 I 2 I 3 I 4 I 5 I 6 I 7 I 8 I 9 Last
 
Question:-

Get the first 200 characters of a string without breaking HTML tags at the end

 
Answer:-

<?php

function closetags($html) {

preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result);

$openedtags = $result[1];

preg_match_all('#</([a-z]+)>#iU', $html, $result);

$closedtags = $result[1];

$len_opened = count($openedtags);

if (count($closedtags) == $len_opened) {

return $html;

}

$openedtags = array_reverse($openedtags);

for ($i=0; $i < $len_opened; $i++) {

if (!in_array($openedtags[$i], $closedtags))

{

$html .= '</'.$openedtags[$i].'>';

} else {

unset($closedtags[array_search($openedtags[$i], $closedtags)]);

}

}

return $html;

} ?>

Prev   
 
 
 
image
Anil  Bist

Skills    Cakephp

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,
Description:-

in 2006, i Join a web development company in Bangalore and start work on "Ruby on Rail" this is my first web development framework and we worked in this framework and develop four to five project after some time , I moved to JEE/Sturst frame work,

After some time i decided that now times come and I have to go on in my own way and I started a company name is "Soarlogic&q
Explore

 

  Students (9)

Ask 
image
Rohin
Ask 
Sanjay
Ask 
Riya
Ask 
image
deepu
Ask 
image
divya
Ask 
image
Neha
Ask 
image
Pooja
Ask 

Ask 
Neha
 
 

Recommended Classes

image shubham rauthan
I am a b.tech graduate in Information Technology and working as a Software Engineer and i wo...
Professional
image shubham rauthan
I am a b.tech graduate in Information Technology and working as a Software Engineer and i wo...
Professional
Rajendra Kumar
I have more then 5 year of Mobile App Development Experience and have worked in Android Native, I...
Professional