Removing Bad Words

Looking for suggestions on how to handle bad words that might
get passed in through $_GET['item'] variables.

My first thoughts included using str_replace() to strip out such
content, but then one ends up looking for characters that wrap
around the stripped characters and it ends up as a recursive
ordeal that fails to identify a poorly constructed $_GET['item']
variable (when someone hand-types the item into the line and
makes a simple typing error).

So the next thoughts involved employing a list of good words
and if any word in the $_GET['item'] list doesn't fall into the
list of good words, then an empty string gets returned.

Any suggestions on how to handle this?


Array Removing Words

Is there a way I can put some sort of wildcard into the array to ignore words that contains "ing" etc at the end? It's a real hassle when I have to input two of the same words and replace/adding the ing's

$ignore = array(

View 2 Replies View Related

Removing Wildcard Words Using JQuery?

I hope I am able to explain this as easy as possible. Basically I am compiling a list and to do so I need to remove a load of text after a certain trigger word. Example of what I am trying to achieve is here Say I have just pasted a bunch of text in my text box, I want everything removed apart from the first username.

And example would be...
r-u-f-f-i-a-n reblogged this from youaref0rsaken
youaref0rsaken reblogged this from loveeoutoflust
loveeoutoflust reblogged this from yourwatchfuleye
Which I would want to turn in to

With using a textbox with the input, a button and a textbox which would display the output. I have tried doing this using jquery and php preg_replace but cannot get it to function correctly. Is anyone able to help me with this?

View 3 Replies View Related

Removing What Ever String Of Word Or Words Come After A Special Char On A Single Line?

I have a source file that file that contain to be translated strings. Each line of the translation cache files containt a Source string then a delimiter/separatpr █ then the translated string

The original old author did write a nice clean up script that cleans the cache files from duplicates or deletes entire lines from the cache if the old source did not use them anymore. Now I would like to add one more function into that existing code (relevant part below) which is : to delete the entire line when there is absolutely nothing '' coming after the separation key █ for the same line that its examining.I have the feeling it will be 1 line of code somewhere below. But where how does this line look like?


$translation_key_value_separator = '█';

// Read file contents and create a used keys array
$used_keys = array();[code]...

View 2 Replies View Related

$words Array Have Many Words , It Work Only With First Words?

i have array :

PHP Code:

it work some times , but if $words array have many words , it work only with first words , so , what's your opinion ? and it this method is true ? or there are anothr method ?

View 5 Replies View Related

Database Driven - Removing The Navigation Bar Instead Of Removing The Button

I understand Javascript, some intermediate Java, expert html, css, Actionscript. My company has acquired a php-based Web site. It has a button in the global main navigation header that we need to remove. Here is the following script that the php page pulls to populate the global navigation header:

$navigation = @mysql_query("SELECT * FROM navigation WHERE category='main' ORDER BY listing ASC");

Which is then placed into a table by this code:

<table border="0" align="center" cellpadding="0" cellspacing="0">
<td><img src="/_images/nav_divider_white.gif"></td>
<?php while ($nav = @mysql_fetch_array($navigation)) { ?>
<td class="<?php

... remaining original code, etc. Instead of removing the button from the navigation bar, it removes the navigation bar from the page "company" which I thought was interesting but not the achievement I wanted.

View 2 Replies View Related

Calculate The Number Of Words/characters Between 2 Given Terms/words?

Basically - I want to calculate the "Proximity" of various terms. By "proximity" I means Specifically the number of spaces/characters/words that sit between them.


Terms = Word1 / Word2
Chunk = "blah Word1 blah blah blah blah blah Word2 blah"
Proximity = Word1-Word2:5

THe script would see the 2 terms, locate them and then see the distance based on the words that lay between them. A more advanced version would be to examine the semantic structure - and identify whether the terms occur within the same semantic element, or a sibling, or a parent etc. Thus proximity discovery of terms may be within the same paragraph, or in sequential paragraphs, or under the same "parent" (heading) but otherwise separate etc. Further - introducing things like word stemming/relationships/soundings at a later date may be useful too.

I've looked around the net (Google, here, php forums, php script sites). Not seeing anything like it. I can see tools on some sites that do similar (limited) - usually SEO based tools. I want to be able to apply this to "text" in general ... as I may apply it to uploaded word/txt files etc. I'm not seeing any real examples - so I can only assume it's mroe than a trifle to code it. How would I handle variant order of the words (Word1+Word2 / Word2+Word1)? How could I handle identifying proximity within/outside of the same element/structure?

View 1 Replies View Related

Bold Some Words In A String And Remove Some Unbold Words?

I am creating an Image Search Engine. Currently, my script does bold the matching words on the keyword. But, some keywords are too long just like the followings. When I search for shah rukh khan, there is an image with the following keyword.

25216d1235653089 shahrukh khan s
wallpaper shah rukh actor

As you see, the above keyword is too long. So, I need it to be like the following one.


Currently, I am using the following code but it requires a space before and after the bold tags. So, if the 1st word is bold, it displays the whole keyword.

$img_keyword = preg_replace('/(.*?) <b>(.*?)</b> (.*?)/us'," <b>$2</b> ",$img_keyword);

View 2 Replies View Related

Counting Words And Cut After Specific Total Words

This is my code to count words in a post: PHP Code:

View 6 Replies View Related

Perform Search Onto Words And Display The 2 Words

so far on page one it takes word from text box and produces search on datebase for that word then produces correctly over the folling pages using pagination. question is i want it to now perform search onto words and display the 2 words. code is below. :_

$carrymake = (isset($_POST['carrymake']))? $_POST['carrymake'] : $_GET['carrymake'];

$carrymodal = (isset($_POST[carrymodal ]))? $_POST[carrymodal ] : $_GET[carrymodal ];

i want to know now how to include the second varible in this code here:-

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prev.'&carrymake='.$carrymake.'"><<Previous</a>&nbsp;'

View 1 Replies View Related

Preg_match_all : Replace Multiple Words With Different Words?

$post[message] is the text of a post from my forum.

I wanted to take out all the text and keep only the text between [TAG1] tags

here is a part of the code i am using to do that:

$string = $post[message];
$tag = "TAG1";
preg_match_all("#[".$tag."](.*)[/".$tag."]#Ui", $string, $matches);


View 14 Replies View Related

Replace Words - Ignore Words Between Brackets?

I'm using an ubb parser to convert several codes within brackets to html codes. I want to use a string replacer aswell to replace some unwanted words.

Now, I'm using this:

foreach($f AS $value) {
$escapeNamesArray[] = '/'.$value['woord'].'/i';
$escapeNamesReplace[] = '<span style="color: gray;">'.$value['vervanging'].'</span>';


When I want to replace the word "Hello" to "Hey", everything is working fine. But when I place the word "Hello" between brackets, for example:


The word "Hello" is replaced aswell. How can I change the pattern of the preg_replace function to ignore words between brackets?

View 4 Replies View Related

Wrap Words Or Words Sequences Which Have Not Been Already Wrapped?

I'm trying to wrap words and words sequence from a given list with preg_replace. It almost works, but there are some use cases it doesn't and I can't figure it how. For instance I do this:

// sort by descending length
usort($this->_keywords, function($a,$b){return(strlen($a)<strlen($b));});
// wrapper is -%string%-


From this keyword list:

sit amet


I'd like to result in:

-Lorem- -ipsum- dolor -sit amet-,
consectetur adipiscing elit. Phasellus
rhoncus venenatis orci sed porta. Sed


View 2 Replies View Related

Converts Singular Words To Plural Words

I am looking for a class that converts Singular words to Plural words. My aim is to take something like Story for a model name and create a Story.php file and a stories.php file. I already have the generator class ready to roll just hoping there is some prebuilt class for converting singular to plural word otherwise i'll start this the most expected ones and work from there.

View 2 Replies View Related

Organize Words So Can Fit The Most Number Of Words In A Given Length?

I'm looking for a way to do the following. I have a list of words of various char lengths. I have a limited number of chars I can use in a given strings size. I'd like to organize the words to fit as many of them as I can in a given string without going over the limit or cutting any of the words off.



I have a limit of 140 characters to fit them all in, including spaces. If I have more names than space avail in that string, I'd like to generate another string using the same function as described above until all the names in the list are used.

View 1 Replies View Related

Punctuate Words If It Contains More Then X Number Of Words?

When a word gets to long it messes the text up.... how can I fix this?


Make a word with 4 chars like "cats" into "ca..."

How would I do this?

View 1 Replies View Related

Count The Number Of Words Between Two Words?

How can i count the number of words between two words?


Now i have this regular expression:


View 3 Replies View Related

Reads In A String And Reverses All Of The Words Inside Of The String (the Words Stay In The Same Position But Are Reversed)

A function that reads in a string and reverses all of the words inside of the string(the words stay in the same position, but are reversed).

function(String sentence){
String word="";
String reversedSentence;
for(int i = 0; i< sentence.length; i++){
if(sentence[i] == ' '){
reversedSentence += reverse(word);
word = "";

View 9 Replies View Related

Echo 5 Words Before 5 Words After

I have a keyword "car" in the sentence. one two three four five six seven car eight nine ten eleven twelve thirteen fourteen fifteen. i'd like it to echo three four five six seven car eight nine ten eleven twelve because 5 words before and 5 words after, including car.

View 4 Replies View Related

Removing Www.

Alot of my users are adding www. to their email when they signup, and id like to silently remove this if its the case

PHP Code:

$string = ''

if(eregi('www.',$string)) echo "yes";

This doesnt work, and im wondering where i went wrong? Ive been up for a long time, and im probably just over looking somthing.

View 1 Replies View Related

Removing One Key

removing one key=>value element from array: I have an array of this sort:


[#document]=> <?xml version ="1.0"?>


I wanted to get rid of the first Key=>value element which is #document=> <?....?>

because my insert statement then gets stuck at this point because of this unwanted element:

insert into table (#document,filename,subscriptionstatus,trackingnumber) value ('"<?...?>','..',...);

View 1 Replies View Related

Removing &

I'm having problems when the string has &'s in it, as well as 's. I was able to remove the 's. But i get a return value of 0 when trying to do the same thing with &'s. If i take out the part where I'm trying to remove &, the value of $replace is OK.

$ini = parse_ini_file('config.ini');

echo $unitname;
echo $replace;

View 1 Replies View Related

Split A String Into Words. Ex: "stringintowords" -> "String Into Words" ?

What is the right way to split a string into words ?(string doesn't contain any spaces or punctuation marks)For example: "stringintowords" -> "String Into Words"! Update: For those who think this question is just for curiosity. This algorithm could be used to camеlcase domain names [URL]...."and this algo is currently used by aboutus dot org to do this conversion dynamically.

View 10 Replies View Related

Removing PHP Coding

I have php coding that is stored in mysql blobs. Now I want to index words in these blobs in an attempt to make some sort of a search engine. Example: How can I use php to make this mysql text:

"Once upon a time there were <?php echo $num_bears ?> bears in a small cage in a zoo in Russia. They had <?php echo $num_relatives ?> relatives that lived there with them."

Change into this: "Once upon a time there were bears in a small cage in a zoo in Russia. They had relatives that lived there with them."

Point is: - remove everything between and including "<?php" and "?>" I'm trying to do some indexing, and I need to remove all my php coding... :)

View 2 Replies View Related

Removing Characters

I am passing a string over to a calculator form but need to strip out the and ,
the string comes over as /index.php?price1=195,000 this populates an input field as below
<input type="text" name="price1" class="fields" value="<? if ($price1 != "") { echo $price1; } else { echo "100000"; }?>"> I have added at the top of the page

$price1 = str_replace("", "", $price1);
$price1 = str_replace(",", "", $price1);?>

this strips the but gives an error with the comma.

View 2 Replies View Related

Removing Whitespaces

I try to remove whitespaces from a string using the preg_replace function

preg_replace("/[ ][ ]*/"," ",$string);

This works great, but makes no handles all characters in the same way. I
want to preserve data between double quotes. So,
hello world "It is a sunny... world"
shall be reduced to
hello world "It is a sunny... world"

and should not remove the whitespaces between the quotes.

View 1 Replies View Related

Removing File

I created a dir with a file in it, using php. I set the file mode to 'w'. It worked and everything, but now i can't delete the file. I tried deleting it using php, in ftp, and in ssh. I can't set chmod mode either. I tried chown but that doesn't work. For anything you do, it shows "Operation not permitted".

View 4 Replies View Related

Removing The .php From Pages

Hi i am new here we run a website called and i was wondering if it is possible to remove the .php from the end of a address

For example, it would be nice it I could have it as

Is this possible does anyone know how to do it and if so where i could look for the code advise etc.

View 1 Replies View Related

Removing Non Characters......

I wanna remove everything else but a-z in my source file ........and replace everything that is not a-z with nothing. I have the below example (but it's getting a parse error). Actually is there an easier way to remove noncharacters (e.g. !@$*$%) from my source file.

$q = $stringoftext
$search = array (""'#'","'$'","'%'","'&'","''","'/'","'@'","'!'","'('","')'","'['","']'","'.'","'+'","'-'","'*'","'{'","'}'","'?'"");
$replace = array ("");
$body = preg_replace ($search, $replace, $q);

View 3 Replies View Related

Removing Character

how do i remove the right most character from a string, and store this in another variable,i want to keep the original variable but without the removed character.

View 1 Replies View Related

Removing Comments

I happen to have a bunch of stuff in a database(who here doesn't right?)and in one of the feilds I have a list of html snidbits that are deliniated by html style comments. I did this so the whole field could be displayed in an html page and the user would never see the delination. However the bossman is for whatever reason very parinoid about having comments in the end html.

Anyways enough backstory - I need to write a script that will take html comments out of a given string without removing other html tags.

View 1 Replies View Related

Copyrights 2005-15, All rights reserved