String Search - Search A String Of Text & Return A TRUE Value.
I'm trying to do something pretty simple but I'm stuck on what function I need to use. Basically, I have a script where you can type a message and submit it. But I don't want people to use bad words, so if they do, it displays an error message. Example:
$string = "Fudge off!"
Let's say I don't like the word "fudge"
if ( stringcontains('fudge', $string) {
echo "No cussing!"
} else {
Post the string
}
Does that make sense? I'm basically trying to find some kind of search that will search a string of text looking for the word "fudge" and if it finds it, return a TRUE value. Does such a function exist?
View Complete Forum Thread with Replies
Related Forum Messages:
Search A String Of Text...
I would like to search a string of text for "x" if "x" is found then it echo's something, else it echo's something else... Anyways I'm kind of lost as to the best way to search a string of text (for example "1,2,3,4,5,6,7,8,9,10,11,12") and find lets say "7,"...
View Replies !
Search Through A String For Various Text
My users enter text into a database field in the form of: this file {link:afile.pdf} is big and this file {link:another.doc} is small. I have no idea how many times they may enter {link:xxx} into a given field. The code we worked out (see other post below) fabulously translates the text into a hyperlink. The problem is that no matter how often the {link:xxx} is in a given field, I only ever get the first file returned; i.e: This file afile.pdf is big and this file afile.pdf is small. But what I should get is, obviously: This file afile.pdf is big and this file another.doc is small. I need to use some kind of looping function, or a foreach type function. Does anyone have any clues? Code:
View Replies !
Search String In Text File
i need to search strings in text file. the string to be searched are in an array: string = array(?',?', '...............'); so how can i read the text file n for each line, find those string in the array?
View Replies !
Regex - Search A Text Field And Grab Every Instance Of A String
I need to be able to search a text field and grab every instance of a string that falls between <tag class="name"> and </tag>. We can assume that the tags will always be written properly. So if the following is my text field: "They streamed across the Clemente Bridge, docked along the <tag class="name">Allegheny River</tag>, strolled from the North Side and biked down the trail to watch their Pirates. <br/> They filled <tag class="name">PNC Park</tag> to the last sliver of standing-room space on the rotunda, <tag class="name">37,259</a> strong. <br/> And they came in full throat, chanting and cheering from the outset." ....I'd need the code to return, probably an array, like this: $array[0] = Allegheny River $array[1] = PNC Park $array[2] = 37,259 I just can't get it.
View Replies !
Search String Delimited In Another String
I have a string (Website referrer). Example: http://www.google.com/search?q=MY STRING HERE&hl=tl&client=firefox-a&channel=s&rls=org.mozilla:en-US:official&hs=dXZ&start=30&sa=N I need to extract the keywords searched (example in the above case: "MY STRING HERE"). I think I need the string between "q=" and the next appearing "&". How can I do this?
View Replies !
String Search
I am building an email system. I want to allow users to add their own html code and also to track who click on the links on this email. for this I need to find all the links in the html string that the user inputs in the form. What I want to is once the html code has been submitted analize it, find all the links in it and then present them in a list to the user so he can decide what he wants to track. Once he has made his choice I need to get back to the html string and replace those links with a piece of code that will allow me to track the clkick through. Is this possible at all? Also, Is there any way to track how many emails bounced back and how many autoresponders?
View Replies !
Search String
if the string has 2 or more periods (anywhere within it to only take that after the second period(looking from teh right)? and if the string has only one period then I look at the whole string?
View Replies !
Search For String
I am having difficulty with the following. PHP Code: CREATE TABLE ptpfullpageapproved ( domain varchar(250) NOT NULL ) TYPE=MyISAM; PHP Code: CREATE TABLE ptpfullpagehistory ( username varchar(50) NOT NULL default '', referringip varchar(15) NOT NULL default '', referringsite varchar(250) NOT NULL default '', referringdate date NOT NULL default ��-00-00', valid char(3) NOT NULL default '' ) TYPE=MyISAM; I would like the query to loop through ptpfullpageapproved and for each value loop through ptpfullpagehistory and count the number of occurences the string $domain is found within $referringsite. I will also need the query to include these additional where statements: username='$id' valid='Yes'
View Replies !
Search A String For A Specified String
How would I search a string for a text like: $string = "My string goes here, do you see?"; $search = " h"; if php_super_cool_search_function($string,$search) > 0 echo ("found!"); else echo ("nothing found, sorry"); What could be the php_super_cool_search_function?
View Replies !
Search String Partially
I search this string for non-alpha numeric chars and get rid of them. $my2 = preg_replace("/[^a-zA-Z0-9s]/", "", $my); What i want to do is the same but allow the string to keep a '.' or a '_' (dot and underscore). eg my3_one.txt is a string i would allow but my3*one.txt is not allowed. How do i do this ?
View Replies !
Search String For Substrings
I'm trying to search for all the strings in some text, marked in between --- & ---. eg. $string = "abc ---yahoo--- hello there ---anyone---"; From within the string, I would like to return the words "yahoo" and "anyone" only into some sort of array. I cannot think of a way to do this. There doesn't seem to be a pattern matching string function in the php library.
View Replies !
Search And Replace In String
Im using the following to search for charictors in a string that are causing problems, and placing a infrount of them. Im trying to do it using: <?php $str = "string's"; $invalied_chars = array(" ", "'"); $result = str_replace($invalied_chars, "", $str); echo $result; ?> The bit im confused by was how to keep the old charictor, just proceeding it with a rather then replacing it?
View Replies !
Search String After Explode
How to search the string after explode $name=$_POST['name'] $lines= file(data.txt); foreach ($lines as $line) { $text_line = explode(":" , $line); } Search the name in $text_line[0] whether the name is present or not
View Replies !
Search A String Using Eregi
Im trying to search a string using eregi, but its not finding what i want even though i know that its there. If i had a string "aaabbbbaaa" and searched for bbbb, would it find it? or is there another better way to do this?
View Replies !
Search For A String In A Variable
Search for a string in a variable Is there a way to find a particular string in php. For example: I want php to echo "Found" if the word "sports" in found in this url http://yahoo.com/sports/soccer/index.html if not then it should echo "bad Luck" Is there any pre-defined function for this in php?
View Replies !
Better Method For Search And Replace In String
Here is an example of the type of string I am trying to search and replace, Generic text about *2nothing~ in particular. Just need to *5extract certain~ characters out of the text. I need to search the string for "*", collect the number directly after the "*", then extract the text, and watch for the "~" character to denote the end of the text. Then the information is sent to a new function i.e. new("2", "nothing") The new function formats the data and returns it into the original string. Currently I am just looping through the string and replacing as I go, but I imagine their is a better and more efficient way.
View Replies !
How To Replace An Item In The Url Search String
Using PHP 4, what is the most elegant way to replace a parameter value in a url query string? I want to replace the "Order" parameter, but it could occur anywhere in the query string. myfile.php?Param1=Hi+there&Order=ColumnA&Param3=Bye+Bye myfile.php?Order=ColumnA myfile.php?Param1=Anotehr+example&Order=ColumnA after applying this function, I'd like the result of the above examples to be myfile.php?Param1=Hi+there&Order=ColumnB&Param3=Bye+Bye myfile.php?Order=ColumnB myfile.php?Param1=Anotehr+example&Order=ColumnB
View Replies !
Brackets <> Screwing Up My String Search
I am trying to perform a match on strings of data. Each string will be a line from an email template. I want to extract the info from each header in the template. What I have works well, so long as there are no brackets <> in there, like what normally surrounds an email address. Code:
View Replies !
Preg Match :: Search String For A URL
The following link is in the string <a href=http://mysite.com/page.php><img src="http://mysite.com/img.gif" /></a> i'd like to search the entire string for that specific url. then would like to get the location of the image that is inside the <a> tag .
View Replies !
String Search To Make Sure It Does Not Already Exists In The Database.
In MySql database I store the restaurant names like "My Restaurant & Bar" On the website before people can add a new restaurant they must search for that restaurant to make sure it does not already exists in the database. The problem is that when people search for "My Restaurant & Bar" the restaurant "My Restaurant & Bar" that already exists is not found.
View Replies !
Search A File/more Efficient To Use A String Or Array?
I'm aware PHP can read the entire contents of a file into a string then from there it's possible to search that string for some data. And I'm also aware that PHP can read the entire contents of a file into an array then from there it's possible to search that array for some data. But can PHP search a file (such as a .txt or .html file) for a string of data? If not, then I guess I'm stuck with the first two options I listed. In that case, lets say I have a .txt file with a bunch of text in it. I want to locate a specific phrase within that text file. Is it more efficient (faster results) to read the contents of that .txt file into a string or an array? Then perform the search.
View Replies !
Mysql Or For Search (select Part Of String)
I am creating a search function and i want to select say only 100 characters (or pref. 40 words) before and after the returned phrase in the results. so far i am using: $get = mysql_query("SELECT * FROM posts WHERE content LIKE '%".quote_smart($query)."%' ORDER BY $order") or die("Cannot search: ".mysql_error()); i tried to use SELECT id, title, tid, uid, LEFT(content, 50) FROM POSTS.... but the query returned none of the content? any ideas? Code:
View Replies !
Search A String For A Specific-size Integer.
I need to search a string for a specific-size integer. For example, the string would be: "This is my string 123456789 and it contains an integer." In all my string values, the integers are all exactly 10 digits in length, and there are no other occurrences of this length integers. I would like to figure out a PHP function to search for any 10-digit-length integers in the string.
View Replies !
HT://dig And Other Search Engines Wont Look At Query String In Links
I realize that this is no the HT://dig support forum but I haven't been able to get htdig to index my site properly: It will only show one file: index.php when every other files is linked off the main page (i.e. index.php?content=page2.html ) I believe that this search engine is not looking at the QUERY_STRING properly or following the links off the main page. Does anyone know how to get htdig to work on a dynamically generated site - or can you recommend another search engine that would help index and search such a site.
View Replies !
How Would You Search For A Part Of A Word In A Whole String Or Flatfile Line.
How would you search for a part of a word in a whole string or flatfile line. for example like: the user inputs tax or another word and if the input is part of a larger word like taxation then it will print the result. Im trying to create a search that will allow the user to input small words and it will search the whole file and if a string with that file is found it will print it.
View Replies !
How To Search Strings Escaped By Mysql Real Escape String()?
I am currently developing an article script and there are Titles and Contents. To prevent sql injection, people say we must use mysql_real_escape_string(). So let's say if there is a Title that says "My Friend's best friend", if I look into the MySQL table record, the text will be saved as "My Friend's best friend", where the apostrophe is escaped. Code:
View Replies !
Search Database And Redirect If True Or Fail If No Match
I have a database of UK postcodes. If a user enters a matching postcode into a text field on a HTML or PHP page then they get taken to a "success page" where as if they enter a postcode not in the database then they get a "fail page" I have a rough idea how to connect the database and search via "SELECT * FROM ... etc" but after this i am sadly lacking in knowledge.
View Replies !
How To Return Just First-line From A Multi-line String Of Text?
I've been looking through the manual for string commands, and I haven't had success in determining the proper call for this, if there is one: Let's say I have a text string with hard-carriage returns in it: "The lazy brown fox ran down the road to the store and bought some eggs to bake a cake and serve dinner for all his friends." So if that string value is in "x", how can I tell it to return JUST the first line: "The lazy brown fox ran down the road"
View Replies !
String Replace :: Delete All [img] Tag In A Text String
i need a function that delete all [img] tag in a text string for sample: $string = This is my text [img:Blue hills.jpg,align=,width=700,height=525,vspace=0,hspace=0,border=1] it's contain many [img:rings.jpg,align=,width=400,height=325,vspace=0,hspace=0,border=1] i want to delete it"; i want affter processed $string will be "This is my text it's contain many i want to delete it". and two jpg file that included in that tag will be save in a array like this: $image[0] = "Blue hills.jpg" , $image[1] = "rings.jpg" .
View Replies !
Database Search Return
I have created a database search page that will return all rows matching your input. The page works fine except during initial loading. The PHP script returns information on all rows. Once you enter your search criterial and click submit you will only get return data specific to that search.
View Replies !
Return Search Results On Same Page
I'm struggling with this much longer than I think I need to, How do I make the results of a search display on the same page as the search, sort of beneath the 'submit' button? Thanks for helping out.
View Replies !
Php / Mysql Search Results Return
Basically I am searching an SQL DB with text brought in from an HTML form. I've checked and the correct string is being passed to the query. I am trying to return the value "cvalid" from the row which is returned based on the search for $lookup in "cname". PHP Code: $lookup = $_POST['user']; $sql = "SELECT cvalid FROM user WHERE cname = '$lookup'"; $result = mysql_query($sql) or die('mssg to be confirmed'); // test result display echo $lookup; echo $result; It seems to return the correct $lookup, but "Resource id #5" as the $result. What am I doing wrong?
View Replies !
Dbase Search Wont Return Error
i have the following php search a database, and everything works fine except if no records are are found i just end up with a blank page. i want an error to be written to the page saying that no records were found or something. PHP Code:
View Replies !
Regular Expression Search On Field And Return Yes Or No
In MYSQL, I have a table field that looks like this: "bobby,ryan,bryan,john" I want to do a regular expression search on that field and return yes or no if "bob" is in it. "bob" is part of bobby, but I would want a search like this to be false. I only want true if bob is actually in there separated by a comma or at the beginning or end of the string. How do I do this?
View Replies !
Echo Message On Search Blank Return
I've got a wee issue concerning a misbehaving piece of php code. What I am trying to achieve is that when a site visitor does a search and the search comes back blank rather than just going back to the search form a message is diplayed to advise that there are no properties available for that date search range. The search form looks at the sql database and is accessing a particular part of it referred to as Abacus. What is happening is that they echo displays irrespective of whether there are search results or not - naturally, I just want it appear when there is nothing to display. Code:
View Replies !
|