Jump to content

remove every other <br />


mgeneral

Recommended Posts

  • 3 weeks later...
This is VERY inefficient, but would work:
[code]<?php

$str= "This text<br />has too<br /> many breaks<br />in it.<br /><br /> Let's take some <br /> of them <br /> out.";

$strAry = explode("<br />", $str);

$str = "";

for ($i=0; $i<COUNT($strAry); $i=$i+2) {
    $str .= $strAry[$i];
    if (isset($strAry[$i+1])) { $str .= "<br />" . $strAry[$i+1]; }
}


echo $str;
?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/27559-remove-every-other/#findComment-136416
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.