Page 1 of 1

php translating using strpos??

Posted: Fri May 27, 2011 7:43 am
by timoteo
Hi,
I'm sure this can be done in an easy way. This is my problem. I have a program I have written to translate job titles from spanish to english and vice versa. There are a couple of hundred of these. I need an easy way to be able to recognize the words with their different endings. eg.
'cocinero', 'cocinera', 'cocineros', 'cocineras' and all come up with cook as the translation. The example below only recognizes 'cocinero' and ignores 'cocinera'.
Investigating around maybe I can use 'strpos' to avoid writing out all my entries 4 times. But not sure how to go about this in the most concise way.

Code: Select all

if ($rowtr['businesscategoryesp'] == "cocinero") {  $updateSQL = "UPDATE businessdetails SET businesscategory = 'cook' WHERE userid = '$u' AND recoentryid = '$re';"
Grateful for any ideas
Thanks

Re: php translating using strpos??

Posted: Sat May 28, 2011 9:46 am
by timoteo
Resolved:
Fixed my own problem, if anyone comes looking for answers:

Code: Select all

$mystring = $rowtr['businesscategoryesp'];

$find ='contador'; $res=strpos($mystring, $find);  if($res!==false) {  $updateSQL = "UPDATE businessdetails SET businesscategory = 'accountant' 

Re: php translating using strpos??

Posted: Sat May 28, 2011 9:48 am
by timoteo
this finds and matches: contador, contadora, contadores, contadoras etc . etc....