Jesper Møller
02-16-2010, 09:24 PM
Im trying to get the preg_replace to replace the word and but cant seem to get it to work :confused:
preg_replace('/ And /i',' og ',$firstname) ;
preg_replace('/ And /i',' og ',$firstname) ;
|
||||
Replace the word "and"Jesper Møller 02-16-2010, 09:24 PM Im trying to get the preg_replace to replace the word and but cant seem to get it to work :confused: preg_replace('/ And /i',' og ',$firstname) ; koko5 02-16-2010, 09:27 PM Hi, try this: preg_replace('/\sand\s/i',' og ',$firstname) ; :thumbsup: Jesper Møller 02-16-2010, 09:43 PM Thank you very mutch :thumbsup: Can you also tell me if i can combine multi replace in one command ?? $firstname = preg_replace('/\sog\s/i',' og ',$firstname); $firstname = preg_replace('/\sand\s/i',' and ',$firstname); $firstname = preg_replace('/\svon\s/i',' von ',$firstname); $firstname = preg_replace('/\svan\s/i',' van ',$firstname); Yes it may look wierd but i have a $firstname = mb_convert_case(trim($_POST["firstname"]), MB_CASE_TITLE, "utf-8"); to make shure the names are with capital letters .. but those word i dont want to be capital koko5 02-16-2010, 09:50 PM $firstname = preg_replace('/\s(og|and|von|van)\s/ie','" ".strtolower("\\1")." "',$firstname); didn't tested but should works :) oops,code edited, because you want to output spaces before and after the string... Jesper Møller 02-16-2010, 10:00 PM Thanks Aha ..( not [ :o That strtolower is smart :thumbsup: Ill try it out |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum