Jump to content

Recommended Posts

Hi everyone, I have this code to help me split a long paragraph into sentences and make every new sentence into a new line. Now i want to insert a bullet point, or a arrow in font of every line. I try many different approaches, but it didn't work. Can anyone point me to the right direction. Thanks for your help.

 

Vanvoquan.

<table border="1" bordercolor="red">
<tr>
<td> 
<p><?php echo stripslashes(str_replace('. ', '.<br />', $product_info['products_description'])); ?></p> 
</td> 
</tr>
</table>

 

Thanks for reply Vitamin. I know we can use the <li></li> tag, but where to put it in this portion of this code.

<table border="1" bordercolor="red">
<tr>
<td> 
<p><?php echo stripslashes(str_replace('. ', '.<br />', $product_info['products_description'])); ?></p> 
</td> 
</tr>
</table>

 

I did try to put the <li></li> tag after the <br /> like this:

<?php echo stripslashes(str_replace('. ', '.<br /><li></li>', $product_info['products_description'])); ?>

 

It gave me the bullet point but in a new line by itself. I need it appear in the front of every sentences. Can anyone please help.

Just an example...

<?PHP
/* replace the content for $MY_PARAGRAPH with the content you are using */
$my_paragraph = "Lorem ipsum his option regione explicari id, eum an ferri decore. Qui ex ridens graecis, debitis placerat eu mei. No est unum decore, ex elit prima eum. Et fabulas appetere patrioque est. Eu elitr labore luptatum sea, ne ullum indoctum comprehensam nam, usu dicta instructior id. Definiebas philosophia ei sed, mei et putent cetero patrioque. Id quo assum dissentiunt. Usu ipsum consul oblique et. Cu quo malis debitis sapientem, et accusam detracto pro, eu aliquid quaerendum est. Nam eu enim gloriatur. Id autem blandit praesent vix. Brute graeco ei eos. An eos sumo porro putant, sit in unum blandit suavitate. Mel ex propriae oporteat comprehensam. Mei consul mediocrem neglegentur an, ea adhuc erant contentiones sit, sea et ferri malis. Vim minim scripserit temporibus ut, an cum harum detraxit.";

/* this is the code for displaying a bullet followed by 2 spaces */
$b = "&#149;    ";

/* create an array from your paragraphm using the period as the delimiter */
$my_array = explode(".", $my_paragraph);

/* count the number of elements in your array */
$count = count($my_array);

/* check to see if the last element is empty - if it is then remove it and decrease the element count by 1 */
$last_element = $count - 1;
if(trim($my_array[$last_element])<1) {
$junk = array_pop($my_array);
$count = $count - 1;
}

/* display the results - for example purposes, we as lso showing the original paragraph */
echo "The paragraph...<p>";
echo $my_paragraph;
echo "<hr>";
echo "The paragraph sentences, listed with leading bullets and spaces...<p>";
$i = 0;
while($i<$count) {
echo $b . trim($my_array[$i]) . ".<br>";
$i ++;
}
?>

http://nstoia.com/test/bullet.php

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.