| | |
find a word and delete
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2009
Posts: 37
Reputation:
Solved Threads: 1
what i want to do is find a word from a text file and delete that word using php plzzzzzzzzz help me.........
i can find the word using this codes
i can find the word using this codes
PHP Syntax (Toggle Plain Text)
$handle = file_get_contents("files.txtl",NULL); $a="first"; $a=substr_replace($a, '0', 0); $a=explode(" ",$a); $c=0; foreach($a as $y){ if (stristr($handle,"$a[$c]")) $b[]= 'yes'; else $b[]='no'; $c++; } if (in_array("no",$b)) echo '<br><br>did not match'; else echo '<br><br>we have a match';
Last edited by ruwanaru; May 3rd, 2009 at 12:05 pm.
•
•
Join Date: Jan 2008
Posts: 141
Reputation:
Solved Threads: 19
PHP Syntax (Toggle Plain Text)
$strText = file_get_contents( 'file.txt' ); $strFind = 'word'; $blMatch = false; if( preg_match( "/$strFind/", $strText ) ) { <blockquote>$blMatch = true; $strText = str_replace( $strWord, '', $strText );</blockquote>}
That will tell you if your word is found, and it will remove it from the string.
R.
Last edited by Ezzaral; May 3rd, 2009 at 3:18 pm. Reason: Fixed code tag
![]() |
Similar Threads
- Error trying to perform single word searches in address bar. (Viruses, Spyware and other Nasties)
- Dns errors or cannot find server on IE6 (Viruses, Spyware and other Nasties)
- Searching word for word (C++)
- Spellchecker Remote (JavaScript / DHTML / AJAX)
- quick little assistance on silly word count!! (C++)
- I hate Firefox! (JavaScript / DHTML / AJAX)
- works for static need help to make it dynamic (C++)
- String operations (C)
- My other half's HiJackThis log, please help (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: add a new item to XML file using PHP
- Next Thread: sync database localhost to hosting data
| Thread Tools | Search this Thread |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login loop mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode update upload url validator variable video web xml youtube





