Removing Bad Words

Feb 22, 2006

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?

ADVERTISEMENT

Array Removing Words

Apr 17, 2007

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(
'/add/',
'/adding/',
'/and/',
'/show/',
'/showing/',
);

View 2 Replies View Related

Removing Wildcard Words Using JQuery?

May 19, 2011

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
r-u-f-f-i-a-n
youaref0rsaken
loveeoutoflust

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?

Mar 29, 2011

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?

EXISTING CODE:

$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?

Jul 4, 2009

i have array :

PHP Code:
$array1=array("donkey","cat","****");
[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

Sep 17, 2010

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 header.inc 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">
<tr>
<td><img src="/_images/nav_divider_white.gif"></td>
<?php while ($nav = @mysql_fetch_array($navigation)) { ?>
<td class="<?php
[Code]....

... 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?

Apr 7, 2011

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.

Example:

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?

Oct 31, 2009

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.

[code]....

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.

if(strlen($img_keyword)>30){
$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

Jul 21, 2001

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

Dec 21, 2004

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?

Jun 5, 2009

$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:

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

[Code]....

View 14 Replies View Related

Replace Words - Ignore Words Between Brackets?

Jun 21, 2010

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>';

[code]....

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:

[code]...

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?

Oct 13, 2010

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%-

[code].....

From this keyword list:

lorem
ipsum
sit amet

[code]....

I'd like to result in:

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

[code]....

View 2 Replies View Related

Converts Singular Words To Plural Words

Mar 31, 2010

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?

Sep 25, 2009

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.

Bobby
Sally
Joe
Sue

[code]....

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?

Sep 27, 2010

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

Example:

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?

Jul 21, 2010

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

[code]....

Now i have this regular expression:

[code]....

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)

Oct 22, 2010

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).

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

View 9 Replies View Related

Echo 5 Words Before 5 Words After

Mar 21, 2010

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.

Mar 29, 2006

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 = 'www.email@yahoo.com'

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

Aug 10, 2007

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

array(

[#document]=> <?xml version ="1.0"?>
[finemae]=>2344ddd
[subscriptionstatus]=>unread
[trackingnumber]=>45566

}

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 &

Mar 27, 2007

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.

Quote//PARSE INI FILE.
$ini = parse_ini_file('config.ini');

//REMOVE APOSTROPHES FROM NAME.
$and="&";
$ini1=$ini['UNITNAME'];
$unitname=str_replace($and,"AND",$ini1);
echo $unitname;
$replace=str_replace("'","",$unitname);
echo $replace;

View 1 Replies View Related

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

Aug 12, 2010

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

May 8, 2002

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

Apr 12, 2002

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

Feb 27, 2006

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

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

Feb 8, 2003

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

Sep 24, 2007

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

For example www.example.com/newsinbrief.php, it would be nice it I could have it as www.example.com/newsinbrief

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

Jul 27, 2007

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

Nov 5, 2007

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

Dec 31, 2003

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

Removing Leading 0

Mar 2, 2006

is there a function for removing a leading 0 from expample 09 or 03 so they will become plain 9 and 3.

View 10 Replies View Related

Removing A Leading Zero

Nov 27, 2005

for example I want to remove the leading 0 from this var

$var = 01

how would I do this ?
at the moment im using
ereg_replace("0", "", $test[&#392;']);

but this deletes all the 0 zeros.

so

$var = 30;

becomes 3 which i dont want,

View 5 Replies View Related

Removing In Email

Mar 1, 2006

I have a simple html form going to email (no db). I've tried both using htmlentities() and stipslashes() on my $POST variables but still the email shows a backslash before special characters.

View 1 Replies View Related

Removing Rows

Mar 9, 2006

is there a way to remove rows that contain duplicate data in a specific row. For example, Table A has columns X, Y, Z. if a few entries were like:

1, 2, 3
g, v, d
6, 5, 3
7, 5, 5
4, 3, 3

As you can see, in column Z, 3 appears three times. Is there a way to delete two of them? (does not matter which one is left). This is only a simplified example, in reality there are four-five columns that must be unique like this. If there is a SELECT statement that could produce these results that would work too.

View 3 Replies View Related

Removing Whitespace

Jul 17, 2005

Here is the code I use to change whitespace from a string $test to hypen -.

<?Php

$test="Teststring test test hay man test test test test";

// Chr(32) is ASCI code for whitespace and Chr(45) is for -

$test = str_replace(Chr(32), Chr(45), $test);

echo $test;
?>

I have to take out the whitespace completely form the string. I will be thankful if anyone can help me, or guide me to the function name that can be used for this.

View 5 Replies View Related

Removing .jpg Extension

Mar 31, 2006

How would I go about removing the file extension of a variables contents?

$variable = "imageone.jpg";

?

View 1 Replies View Related

Removing The Submit Value

Apr 9, 2007

I could not think of a better subject. I have a script that reads and writes from a cookie. The problem is that whenever I build the cookie I am always getting the value of the submit button in my output. When, I believe, I should be getting no output at all when I do not send any values. Code: PHP Code:

<?php
       if($_POST["sub"])
       {
            $label;
            $out;
            $td;
                 $label = "<div>Cookie Contains</div>";
                 
                 foreach($_COOKIE as $key => $item)
                 {
                      $out .= "<div>$key = $item</div>";
                      setcookie($key, "", time()-600, "/");
                 }//end foreach
..............

View 1 Replies View Related

Removing %20 From A Variable

Apr 9, 2007

i passed a variable which has a space in it and it puts %20 in it to substitute the space. Is there any PHP function that removes %20 :P?

View 1 Replies View Related

Removing Apostrophe

Feb 10, 2006

Code:

<a href='/inalb.php?show={$row['title']}'>{$row['title']}</a>

In $row['title'] one of the rows being called has a title that contains an apostrophe. I believe it is messin with the code because it is cutting my url short at the apostrophe.
I also need to pass that title later, and I am not sure whether i will be able to do that with an apostrophe in it.

View 3 Replies View Related

Removing HTML

Sep 28, 2007

I have a form that is receiving spam from people, and this is unaceptable. I know that it is impossible to stop all spam, however, I need to stop people from posting links. As of now, I have my function stripping out tags, or anything that resembles tags. ie. <something> That can stop actual links, but now they just type the link. Is there a way to sense if a string has "http://" or "www." etc... to prevent the form from allowing it to procede? I know how to get the prevention to work, I just need to sense it.

View 4 Replies View Related

Removing Return

Oct 26, 2007

I have the following text in an RSS feed I'm trying to create:

Code:

&quot;some text here&quot;

How to I get rid of the  symbol? Already tried to strip whitespace.

View 10 Replies View Related

Removing GET Variables From Url

Aug 1, 2006

I am trying to send information from one page "products.php" to "viewcart.php". so I use <a href="viewcart.php?id=pd_id_1"> ... In viewcart.php I take the 'id' variable, push it in a $_SESSION array 'cart' and then create the cart from a SQL database.

The problem is that whenever the client refresh the page, the $_GET['id'] variable is pushed inside the array 'cart' and I end up with multiple items. I want to get rid of the $_GET information in the url but just can't make it work. Tryed unset() but it doesn't work. If not, is there a way to send $_SESSION variables from a link? Instead of using [...]viewcart.php?#*$!XX to get something like [...]viewcart.php?$_SESSION['id']="pd_id_1"?

View 1 Replies View Related

Removing Spaces

Jan 31, 2007

My database contains some columns's that have spaces in them and some that dont. E.g.

NU 320
NU 311
NU321
NU 321

I want my search to return ones that have a space in them. E.g. When I search for %NU3% I will get all the results listed above instead of jsut the 3rd one.

View 4 Replies View Related

Removing The Backslashes

Jun 20, 2005

$code = $_POST['code'];
fwrite($handle, $code);
mysql_query("INSERT code..blah blah");

I'm taking some html from a form and putting it both in a file and into mySQL. However, this code adds backslashes to everything. The file $code is written to has three backslashes before each double quote, and the $code put into mysql has a backslash before each doublequote once.

View 1 Replies View Related

ADVERTISEMENT