Welcome Guest, Not a member yet? Register   Sign In
Character replacing inside a string
#1

[eluser]developer10[/eluser]
Hello,

it'll be the best if i simply illustrate my problem with an example:

i want to write a function which would replace non-English character by english ones:

$str = "Ovo je nešto o čemu sada nećemo raspravljati";

into

$str = "ovo-je-nesto-o-cemu-sada-necemo-raspravljati";

I'm a bit familiar with the str_replace() function, but how to make it to search for characters (č,ć,đ,š,ž) in one step and replace them by c,c,dj,s,z respectively?

for now, i can do this:

Code:
function f_ime_seo($replace,$bythis,$str)
{
      echo str_replace($replace,$bythis,$str);
}

and it works well, but the problem is i can put into $replace only one character and i want to be able to check for existence of all those character in one step.

Any suggestions would be appreciated! Thanks


Messages In This Thread
Character replacing inside a string - by El Forum - 12-05-2009, 10:13 AM
Character replacing inside a string - by El Forum - 12-05-2009, 10:30 AM
Character replacing inside a string - by El Forum - 12-05-2009, 10:32 AM
Character replacing inside a string - by El Forum - 12-05-2009, 11:10 AM
Character replacing inside a string - by El Forum - 12-05-2009, 11:13 AM
Character replacing inside a string - by El Forum - 12-05-2009, 06:00 PM



Theme © iAndrew 2016 - Forum software by © MyBB