PHP - Get All Words From A Page
I would like to get all words from a site in a array.
I found this great thing: http://simplehtmldom.sourceforge.net/ however it makes use of: file_get_contents which gives me: Warning: file_get_contents() [function.file-get-contents]: http:// wrapper is disabled in the server configuration by allow_url_fopen=0 in And my hosting doesn't allow a change for that, they tell me to use curl. With curl i get this: Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when safe_mode is enabled or an open_basedir is set in It's caused by this line: curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1); But setting it to 0 cause then instead of getting the word from the page i want i get the following words in a array: 302 Moved The Document has moved here What can i do now? Similar Tutorials: : NEW Problem I want to replace bad words which someone has inputted into my HTML textarea, with something like [CENSORED]. Here's what I've got so far: note: $review is the posted textarea name. Code: [Select] $words_text = 'badwords.txt'; $bad_words = file($words_text); $good_words = str_ireplace($bad_words,'[CENSORED]',$review); echo $good_words; The thing is, if I type bad words in the textarea, I still get bad words when I echo $good_words. I don't know why I'm getting this, any ideas Hello dear friends, I've an idea so let us say we have paragraph with bad words Code: [Select] $para = "Hello shit oh shit what the hell this is shit day"; Now let say we create textarea Code: [Select] <textarea id="badword" name="badword"> </textarea> and let us say we have database table as following Code: [Select] CREATE TABLE `banned` ( `id` varchar(50) NOT NULL default '', `badwords` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8; consider we have connetion and can update mysql table badwords 1- now how we can enter word per line in this textarea example we entered in this textarea per line shit hell die death then by click on submit it stored in an database table 'banned' as INSERT INTO `banned` VALUES ('1', 'shit,hell,die,death'); 2- if we called `badwords` from table 'banned' how then can put 'shit,hell,die,death' into array so we can exclude it from $para can someone please help me in this , how to store textarea per line as sperated words in database table and how then call it back as array to exclude it form our paragraph Or it there any other simple way doing the same thank you I'm trying to pull in data using a particular word from a mysql db (it's like a search facility). But this code only picks if the db has got the exact same word. E.g. if fincom = "DALLS" it pulls the data only when "searchwords" has DALLS. It ignores if "searchwords" has BARBIE DALLS. How can I fix this. I need to pick all records which contains the search word 'fincom' anywhere in searchwords. Hope this makes scene. $SomeVar = $_POST['fincom']; $query = "SELECT * FROM news_home WHERE searchwords = '".$SomeVar."' ORDER BY timestamp DESC"; $results = mysql_query($query); I'm pretty sure the problem is starring me in the face, but I can't seem to locate it. function filter($string) { //swear words pulled from bannedwordlist.com $f = fopen('../badwords.txt', 'r'); $bad_words = fread($f, filesize('../badwords.txt')); $bad_words = explode('\n', $bad_words); $input = strtolower($string); foreach($bad_words as $value) { $string = str_replace($value, '****', $input); } return $string; } UPDATED CODE function filter($string) { //swear words pulled from bannedwordlist.com $f = fopen('../badwords.txt', 'r'); $bad_words = fread($f, filesize('../badwords.txt')); $bad_words = explode('\n', $bad_words); $input = strtolower($string); $string = str_replace($bad_words, '****', $input); return $string; } I've already echoed out $value in the foreeach loop, and it does correctly retrieve the bad words and put them into an array. My only problem is, the returned string is still in strtolower() form, and the words aren't censored. :/ Hi there, I'm making an online clothing store for the brick and mortar shop we have and would like the customer to be able to refine their search by size, colour etc. The size options will be XS, S, M etc etc where XS is 0, S is 1 and so on. So when they select XS it will add ?size=0 to the URL, if they select XS and S it will be ?size=0;1 What I need to know is how to make some PHP code which can recognise the ; is a break and know that both sizes are selected. Hope that makes sense and thanks in advance hi, now i have something like this: $pizza = "piece1 piece2 piece3 piece4"; $one_word = explode(" ", $pizza); but i want to get 2 words together, like that: $two_words[0]='piece1 piece2'; $two_words[1]='piece3 piece4'; $two_words[2]='piece2 piece3'; $two_words[3]='piece1 piece4'; if it's impossible with explode, then it's fine if you use some other function, i don't care as long as it works. thank you, tastro Hi, having a really strange problem, i have a form like this: <form method='post' action='addcart.php'> echo $name //prints both parts of name separated by space <input type='hidden' value='$name' name='na' and then in the addcart.php echo $_POST['na'] //only prints first half of name So for example, if $name was "Product One" when i print the value in first script it prints Product One fine but when i print in the other script it only prints "Product". This then leads onto only half the name being copied into a database. I'm sure this was working fine before, not sure what the problem here is... Hi I have a column in my database showing Banned words. What im trying to do is to recall the list of bad words from my database and if some of them is going to be displayed they should replace it with :-x well I made the `$bwords` to recall the info from the database. Sorry if this is very basic. We have our church membership lists in a MySQL database with the following fields: Surname Person1 Person1_Membership Person2 Person2_Membership ... The membership fields will either be empty or contain "Resident" or "Non-Resident". The reason for two columns is that some couples may only have one partner as a member. I am trying (without success) to find a way of getting a total (to display on a web page) of how many "Resident" and how many "Non-Resident" members we have. In other words, I'm trying to get a sum of the total number of times "Resident" and and total number of times "Non-Resident" appears in the two columns combined. (hope that makes sense!) I would appreciate any pointers from anyone who has managed to do this, or something similar, already. Many thanks for the help Hey, I have a search feature that searches for words in my database. I am currently storing all searches that users make in a table called `search`. I need to list the top 10 words that are searched for the most, excluding common words like "the, and, or, etc". Because the searches users make are stored into a table, it should be fairly easy. Could anyone give an example of how to do this? Here's how my sql table looks: table name: search columns: id (autoincrement) phrase date resultsfound ip Hi ,, my frineds , how r u ? I have this article in my script: Quote <<WordPress>> widgets are the dynamic objects which eases the customization of the content on <<sidebars>> and widgetized <<footers>>. <<Widgets>> allows drag-n-drop interface in the Dashboard <<admin panel>>, for easy <<management>>. I want from the script , search about any word have <<..>> and replace it by: <a href="the word.php"> the word <a/> for examle : when the script find this word: <<Hello World>> , directly update it and replace PHP Code: <a href="hello-world.php"> Hello world </a> how can work it .. thank you very much for helping me .. ^_^ hi folks, i have a variable in which some common words are stored and another variable in which a sentence is stored. I want to remove the common words from the sentence> Is there any way of doing this in PHP? Code: [Select] <?php $common_words = "to, this, all, the, from"; $sentence = "I want to remove all the common words from this sentence"; ?>the final output should be: "I remove common words sentence." Hello guys, i need some help in assigning a score to a word according to its occurrence in a group of sentences. Code: [Select] [php] $words="Hello, how are you?"; $sentences="Hello! I am fine. How about you? You look good."; [/php] now i'm trying to assign a score to each word in $words e.g Hello=1, how=1, are=0, you=2. I can't seem to find a decent code function to search for "curse" words that i would deem inappropriate in an array. Count the number of instances the function finds a curse word and then if the number is greater than one halt the script. something like the following but not really.... Code: [Select] $words = array('ass','fuck','shit'); $string = 'Blah blah blah ass blah blah fuck blah blah shit!'; //code to count the instances of the curse words(3) if($instances > 0) { echo "no cursing please."; } ; any help on how to do this would be much appreciated! Hi, I am currently using this code as part of my search module: Code: [Select] $sql_res = mysql_query("SELECT * from test_user_data WHERE streng like '%$q%' or beskrivelse like '%$q%' or sku like '%$q%' ORDER BY streng LIMIT 5"); Simple code that works if my client searches for a string (or part of) that is contained in test_user_data table. If he searches "Dell Inspiron 6000", he will get a hit. However, if he searches for "Inspiron Dell 6000", he will not. Is it a simple way to make the client/enduser search for multiple words contained in a single cell? Thank you! This forum is awesome! I found this regex, which is what I want, here:
(?=.*\bdog\b)(?=.*\bpuppet\b)(?=.*\bfuzzy\b)It is suppose to 'succeed' if it can find all the given words in any order. Yet, when I try to test it against this sequence of words (or any other order of these words): need fuzzy hand puppet in dogpen for dogI get no indication of a match. What am I not understanding? Hi, how can I match two keywords in a string? eg. if keywords (Kids,Hoody) are in this string (Animal Kids Basic Hoody Blue) do something..... Thanks. Hello again to all I would like to ask if how can i removed the first 3 words on this string? Quote Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque hendrerit accumsan turpis, vitae rutrum quam cursus id. Sed quis pulvinar eros. Integer vel tellus turpis. Donec tortor dolor, convallis in mollis et, rhoncus eu lacus. Etiam quam risus, fringilla ac tempor in, congue vel felis. Mauris eu luctus augue. Fusce nisl neque, convallis a posuere a, ultricies et metus. thanks in advance Hi there, I have a HUGE list of inappropriate words in plain text, but the thing is, I want to use these bad words in an array. But I can't just copy and paste the bad words into the array, as each bad word needs to have two apostraphes aside one another. E.g the array should be: Code: [Select] $bad_words = array('badword1','badword2','badword3'); but my text document just has: badword1 badword2 badword3 How do I format the bad words to have apostraphes aside each other? I don't want to manually go through each word. Thanks Hey quick question on my homepage there is a featured content section, which is populated from my DB some of the posts are really long so I would like to limit the amount of text. how can I do this? also is there a way to make sure if does not cut a word in half? thanks |