Jump to content

Remove specific sentence


Makke_

Recommended Posts

I use following code to retrieve data from a database and trim it in different ways to make it look better. and remove unwanted characters and also to be able to use some characters.

Allthough in rc_comment string I would also like to remove if possible a specific sentence Created page with or in worst case the three words.
I have tried to add $newString = str_replace("Created", " ", $newString); to remove the word Created but this doesnt work.

Any idea how to solve this?
 

echo '<table border=0><thead><tr><th></th></tr></thead><tbody>';
$q = mysql_query("SELECT rc_id, rc_title, rc_comment, rc_minor FROM recentchanges WHERE rc_minor = '0' ORDER BY rc_id desc limit 20");
while($f = mysql_fetch_array($q)) {
$string = $f['rc_comment'];
$newString = $string;   
	$newString = str_replace("/* ", "", $newString);   
	$newString = str_replace(" ", "_", $newString);  
	$newString = str_replace("(", ".28", $newString);
	$newString = str_replace(")", ".29", $newString);
	$newString = str_replace(",", ".2C", $newString);
	$newString = str_replace("&", ".26", $newString);
	$newString = str_replace("å", ".C3.A5", $newString);
	$newString = str_replace("ä", ".C3.A4", $newString);
	$newString = str_replace("ö", ".C3.B6", $newString);
	
    echo '<tr><td><span style="color:grey">■&nbsp&nbsp&nbsp&nbsp</span><a href="index.php/'.$f['rc_title'].'#'.substr_replace($newString ,"",-4).'" target="_parent">'.$f['rc_title'].' - '.trim($f['rc_comment'], "/* ").'</a></td></tr>';
}
echo '</tbody></table>';
Link to comment
Share on other sites

I tested it and this should work?

	$newString = $string;   
	$newString = str_replace("/* ", "", $newString);   
	$newString = str_replace(" ", "_", $newString);  
	$newString = str_replace("(", ".28", $newString);
	$newString = str_replace(")", ".29", $newString);
	$newString = str_replace(",", ".2C", $newString);
	$newString = str_replace("&", ".26", $newString);
	$newString = str_replace("å", ".C3.A5", $newString);
	$newString = str_replace("ä", ".C3.A4", $newString);
	$newString = str_replace("ö", ".C3.B6", $newString);
	$newString = str_replace("Created", " ", $newString);
	$newString = str_replace("page", " ", $newString);
	$newString = str_replace("with", " ", $newString);
Link to comment
Share on other sites

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.