I currently have a text area that u type in then u it submit and then it goes to a php file and in that file i want it to retrive data fdrom like 'a'='%','b'='+', and i want it to substitue the letters for the varible or w/e and then echo it how can i do this?
I think a simple [man]str_replace[/man] will work here..
<?php $alpha = array('A'=>'%', 'a'=>'o/o', 'B'=>'+', 'b'=>'t'); // Or whatever you want the replacements to be... $contents = $_POST['textArea']; // Retrieve text from form foreach($alpha as $a=>$rep) { $contents = str_replace($rep, $a, $contents); } echo $contents; ?>
~Brett
that doesnt work.
got it it was a simple string replace im stupid..
<?php $letters = array("A","a","B","b"); $crypted = array("#","-","=","+"); $text = $_POST['text']; $text2 = str_replace($letters, $crypted, $text); echo $text2; ?>
You could also use [man]strtr/man, e.g.
<?php $text = $_POST['text']; $text2 = strtr($text, "AaBb", "#-=+"); echo $text2; ?>