fusioneko Posted October 17, 2007 Share Posted October 17, 2007 I'm back again to annoy you people with a question. main.php <?php include("encconfig.php"); if($_POST['CONVERSION']){ if($_POST['SUBENC']){ $search = $transchartfinda; $search2 = $transchartfindb; $replace = $transchartreplacea; $replace2 = $transchartreplaceb; $CONVFILEVALUE = preg_replace($search,$replace,$_POST['CONVERSION']); $CONVFILEVALUE = preg_replace($search2,$replace2,$CONVFILEVALUE); } else if($_POST['SUBDEC']){ echo "Decoding.."; } } echo "<Form action="."kinaversion.php"." method=post>"; echo "<textarea name=CONVERSION></textarea><textarea name=OUTPUT>$CONVFILEVALUE</textarea>"; echo "<BR><input type=submit name=SUBENC value=Encode>"; echo "<input type=submit name=SUBDEC value=Decode>"; echo "</form>"; ?> encconfig.php: <?php $transchartfinda = 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"); $transchartfindb = 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"); $transchartreplacea = array("y","z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x"); $transchartreplaceb = array("Y","Z","A","B","C","D","E","F","G","H"."I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X"); ?> It just doesn't want to work, I've tried everything D: I'm not the best when it comes to pregreplace, and I just relised it's case sensative. I'm wondering if I should make my own search and replace function using strstr and such. My problem is that preg_replace fails to produce per letter. more like.. Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in C:\wamp\www\kina\kinaversion.php on line 9 Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in C:\wamp\www\kina\kinaversion.php on line 10 Result: Nothing just errors out and fails what I want it to do. Expected Result: I wanted it to change each letter.. to a different letter, now looking at what preg_replace requires makes me want to write another function to do this instead. Quote Link to comment https://forums.phpfreaks.com/topic/73596-encoding-decoding/ Share on other sites More sharing options...
sasa Posted October 17, 2007 Share Posted October 17, 2007 change function preg_replace() to str_replace() Quote Link to comment https://forums.phpfreaks.com/topic/73596-encoding-decoding/#findComment-371361 Share on other sites More sharing options...
fusioneko Posted October 17, 2007 Author Share Posted October 17, 2007 str_replace() worked so far byt it's not working as effectively as I want. Quote Link to comment https://forums.phpfreaks.com/topic/73596-encoding-decoding/#findComment-371596 Share on other sites More sharing options...
fusioneko Posted October 17, 2007 Author Share Posted October 17, 2007 Apparently I can't find my modify button. (EDIT) <?php include("encconfig.php"); if($_POST['CONVERSION']){ if($_POST['SUBENC']){ $search = $transchartfindx; $replace = $transchartreplacex; $CONVFILEVALUE = str_replace($search,$replace,$_POST['CONVERSION']); } else if($_POST['SUBDEC']){ $replace = $transchartfindx; $search = $transchartreplacex; $CONVFILEVALUE = str_replace($search,$replace,$_POST['CONVERSION']); } } echo "<Form action="."kinaversion.php"." method=post>"; echo "INPUT:<BR><textarea name=CONVERSION></textarea><BR><BR><BR>OUTPUT:<BR><textarea name=OUTPUT>$CONVFILEVALUE</textarea>"; echo "<BR><input type=submit name=SUBENC value=Encode>"; echo "<input type=submit name=SUBDEC value=Decode>"; echo "</form>"; ?> ENCCONFIG.php: <?php $transchartfinda = 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","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"); $transchartfindb = 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"); $transchartreplacea = array("y","z","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","A","B","C","D","E","F","G","H"."I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X"); $transchartreplaceb = array("Y","Z","A","B","C","D","E","F","G","H"."I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X"); $transchartfindx = array( "a" => array ("a"), "b" => array ("b"), "c" => array ("c"), "d" => array ("d"), "e" => array ("e"), "f" => array ("f"), "g" => array ("g"), "h" => array ("h"), "i" => array ("i"), "j" => array ("j"), "k" => array ("k"), "l" => array ("l"), "m" => array ("m"), "n" => array ("n"), "o" => array ("o"), "p" => array ("p"), "q" => array ("q"), "r" => array ("r"), "s" => array ("s"), "t" => array ("t"), "u" => array ("u"), "v" => array ("v"), "w" => array ("w"), "x" => array ("x"), "y" => array ("y"), "z" => array ("z"), ); $transchartreplacex = array( "y" => array ("y"), "z" => array ("z"), "a" => array ("a"), "b" => array ("b"), "c" => array ("c"), "d" => array ("d"), "e" => array ("e"), "f" => array ("f"), "g" => array ("g"), "h" => array ("h"), "i" => array ("i"), "j" => array ("j"), "k" => array ("k"), "l" => array ("l"), "m" => array ("m"), "n" => array ("n"), "o" => array ("o"), "p" => array ("p"), "q" => array ("q"), "r" => array ("r"), "s" => array ("s"), "t" => array ("t"), "u" => array ("u"), "v" => array ("v"), "w" => array ("w"), "x" => array ("x"), ); //print_r ($transchartfindx); ?> The current Array I'm using seems to only make it english. Quote Link to comment https://forums.phpfreaks.com/topic/73596-encoding-decoding/#findComment-371631 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.