php translating using strpos??

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

php translating using strpos??

Post 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
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: php translating using strpos??

Post 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' 
timoteo
Forum Contributor
Posts: 125
Joined: Sat Jan 08, 2011 6:46 am

Re: php translating using strpos??

Post by timoteo »

this finds and matches: contador, contadora, contadores, contadoras etc . etc....
Post Reply