Re: Read more link with HTML code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey,

thanks for the help everyone, but after reading all the answers i decided to do some regexp thingies. Came up with this:

   function readMore_closedtags($text, $length) {
preg_match_all('/<(.*?)>/s',substr(stripslashes($text), 0, $length),$out);
       foreach($out[1] as $key2 => $val2){
           if(
               !preg_match("/br.*/", $val2) &&
               !empty($val2)
           ){
               $val2_arr = explode(" ", $val2);
               $val2 = $val2_arr[0];
               if(preg_match("/^\//", $val2))
                   $html_arr_close[] = strtolower($val2);
               else
                   $html_arr_open[] = strtolower($val2);
           }
       }
$not_closed_tags = array();
       foreach($html_arr_open as $tag){
           $key = array_search("/" . $tag, $html_arr_close);
           if($key !== false){
               unset($html_arr_close[$key]);
           } else {
               $not_closed_tags[] = $tag;
           }
       }
$closed_tags_str = '';
       foreach($not_closed_tags as $tag){
           $closed_tags_str .= "</" . $tag . ">";
       }
       return $closed_tags_str;
   }

Mike

Medusa, Media Usage Advice B.V.
Science Park Eindhoven 5216
5692 EG SON
tel: 040-24 57 024 fax: 040-29 63 567
url: www.medusa.nl
mail: mike@xxxxxxxxx

Uw bedrijf voor Multimedia op Maat



Mike van Hoof schreef:
Hello:

EG:

<i>The community of Gbongay, Sierra Leone, suffered greatly after the country's civil war, and had aspirations of starting a beekeeping operation to improve their situation. That's when they turned to NABUUR for assistance. But with Neighbours living all over the world and a Facilitator with no knowledge of bees, could this dream ever become a reality?</i><br /><br /><b>The challenge</b><br />Gbongay, a rural village situated in southeast Sierra Leone, lost everything after the civil war -- the school and hospital were destroyed, and its inhabitants no longer had access to safe water. To try to overcome this tragedy, the community decided it needed to raise money, which could be used to create a small, sustainable business.<br /><br />Beekeeping seemed to be a promising option, since it required only a small investment and had the potential for a high return -- and the proof was in the neighbouring village, which already had a successful honey business.<br /><br /><b>A real leader</b><br />What really got this project started was the project's Facilitator, Raul Alberto Caceres. Born in Colombia, Raul moved to Australia for a post-graduate programme. He now works as a chemical engineer<br />in the food industry and recently joined NABUUR.<br /><br />As the leader of the beekeeping project, Raul designed a detailed plan. He knew they needed to research as much as possible about starting and running a beekeeping operation, and that the assistance of the<br />Neighbours was going to be essential.<br /><br />The Neighbours -- from more than ten countries -- were involved at different stages of the project depending on their expertise. Some<br />volunteers helped with general tasks, like Internet research, letter writing and contacting organisations for information, while others helped with more specific assignments that pertained to beekeeping<br />itself.<br /><br /><b>Quick success</b><br />Gbongay's beekeeping operation progressed quickly -- and it couldn't have been done without Raul's impressive leadership abilities. He showed enthusiasm on the website and was able to mobilise<br />volunteers all over the world, including Turkey, Ghana, Canada and the Netherlands. Because NABUUR volunteers often never have the chance to meet in person, it's essential that a project's Facilitator be an organised and enthusiastic leader. Fortunately for the community of Gbongay, Raul was just that!<br /><br /><b>Beekeeping today</b><br /><img src="http://www.nabuur.com/uploads/img_4512900141172.jpg"; align="right" hspace="15" alt="" />The beekeeping operation in Gbongay has further expanded and now includes a beekeeping school. After some research, the Neighbours and local community decided this would be a great way to<br />ensure the future of the beekeeping business. In March 2006, everyone began work on the school.<br /><br />Today, things are looking better for the village of Gbongay. The community's first water pump has been installed, the first 35 beekeepers have graduated from the new school -- and, best of all,<br />the first customers are buying honey!<br /><br /><b>Bonus</b><br />"Gbongay has been rewarded by nature. It was<br />given the local bee, which is extremely prolific, an<br />abundance of bee flora and a favourable climate<br />for beekeeping -- making this initiative a lucrative<br />one."<br /><br />Mariama Fawundu, Local Representative<br /><br />


With kind regards

Mike

Medusa, Media Usage Advice B.V.
Science Park Eindhoven 5216
5692 EG SON
tel: 040-24 57 024  fax: 040-29 63 567
url: www.medusa.nl
mail: mike@xxxxxxxxx

Uw bedrijf voor Multimedia op Maat



Rafael Costa Pimenta schreef:
could you show some example?

2007/5/7, Mike van Hoof <mike@xxxxxxxxx <mailto:mike@xxxxxxxxx>>:

    Hello list,

    I got a problem with displaying content in a "read more block" which
    contains HTML code.
    The problem is as followes:

    I got a large piece of content, which contains HTML code (<b><u><i>
    etc), but after 200 characters a read more link appears. At the
    moment I
    strip al the HTML out of this piece of content, and display the
    full set
    off content on another page.
    But now i also want to display the bold text etc. in the first (200
    chrs) content block. The only problem i have here, is that when I
    got a
bold tag opend in the first 200 chrs, and it's closed after 400 chrs,
    then the rest off the page is also bold.

    somebody got a solution ?

    Thanks for reading.

    Mike

    --
    Medusa, Media Usage Advice B.V.
    Science Park Eindhoven 5216
    5692 EG SON
    tel: 040-24 57 024
    fax: 040-29 63 567
    url: www.medusa.nl <http://www.medusa.nl>
    mail: mike@xxxxxxxxx <mailto:mike@xxxxxxxxx>

    Uw bedrijf voor Multimedia op Maat

    --
    PHP Database Mailing List (http://www.php.net/)
    To unsubscribe, visit: http://www.php.net/unsub.php




--
Atenciosamente,
Rafael C. Pimenta
Programador - CTT Integration Group


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux