arrays - Converting a character to another character in PHP -


i have 2 arrays 1 fake japanese characters, english alphabet have no idea go here, i've tried loops, str_replace, using letters array keys jap array did work 1 word, want break words , convert them while including space.

$name = $_post['engname']; $name = strtoupper($name);  $jap = array('ka','tu','mi', 'te','ku', 'lu', 'ji', 'ri', 'ki', 'zu', 'me', 'ta', 'rin', 'to', 'mo', 'no', 'ke', 'shi', 'ari', 'chi', 'do', 'ru', 'mei', 'na', 'fu', 'zi'); $letters = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');  $names = explode(' ',$name); $letters = array(); foreach($name $names) { $names[] = join('<br/>', str_split($names)); } echo join('<br/>',$names); 

php has function that: strtr

strtr - translate characters or replace substrings

if given 2 arguments, second should array in form array('from' => 'to', ...). return value string occurrences of array keys have been replaced corresponding values. longest keys tried first. once substring has been replaced, new value not searched again.

$name = strtr($name, array_combine($letters, $jap)); 

(not sure in direction want go, jap->eng or eng->jap fact use strtoupper assume latter)


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -