Well i have a list in a txt with some 100ds rows containg a number with 3 digits and a word. I want to remove the number from the list. So i create a script php and i inport all the rows in an array and then i go with str_replace to change the array but it doesnt work can anyone helpme with this? $keyword[$i] = "121 keyword1" $keyword[$i] = str_replace("[0-9]+", " ", $keyword[$i]); I want to take only $keyword[$i] = "keyword1" Can anyone helpme with this?
str_replace doesn't support regular expressions. Check out www.php.net/preg_replace Hope that helps, Jay
Untested but should probably work $keyword[$i] = ereg_replace("[0-9]+", " ", $keyword[$i]); Code (markup):
you can this using this pseudocode get the list and convert them into an array loop through the list, us regex to take out the numbers rewrite the results into a new file
I did that it works but its a little bit noob Any suggestions? $keyword[$i] = str_replace(array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"), "", $keyword[$i]); $keyword[$i] = ucfirst(trim($keyword[$i]));
Well, if you want to go that way ... $keyword[$i] = str_replace(range(0, 9), "", $keyword[$i]); $keyword[$i] = ucfirst(trim($keyword[$i])); PHP: ... is an easier implementation (but the same). Jay