Jump to content

Replacing first letter of every new line?


Bolanb

Recommended Posts

Try this :

 

<?php
$string = '
Some text content content<br />
=content content content content content content<br />
content content content content content content<br />
=content content content content content content<br /> 
content content content content content content ';

//explode your string with new lines.
$string_array = explode('<br />',$string);  // replace  <br />  with \n if you are using normal line break



//now check the array to find out if they contain = at first. 
foreach ($string_array as $line_key => $the_line)
{
     if (substr(trim($the_line),0,1) == '=')
           $string_array[$line_key] = '=<b>'.substr(trim($the_line),1).'</b>'; // replacing the line in array with the bold version.
}

echo implode('<br />',$string_array); // replace  <br />  with \n if you are using normal line break

?>

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.