simple string changer

Discussion in 'PHP' started by ironmankho, Nov 29, 2011.

  1. #1
    simple string changer
    i want to change string 1234567890 into abcdefghij

    
       a$=1234567890;
      $code = str_replace('1', "a", $a);
      $code = str_replace('2', "b", $a);
      $code = str_replace('3', "c", $a);
      $code = str_replace('4', "d", $a);
      $code = str_replace('5', "e", $a);
      $code = str_replace('6', "f", $a);
      $code = str_replace('7', "g", $a);
      $code = str_replace('8', "h", $a);
      $code = str_replace('9', "i", $a);
      $code = str_replace('0', "j", $a);
    
    echo $a;
    PHP:
    but it is not work

    it showing 1234567890
     
    Solved! View solution.
    ironmankho, Nov 29, 2011 IP
  2. #2
    
    <?php
    
    $a = 1234567890;
    
    $numbers = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0");
    $letters = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j");
    
    $change = str_replace($numbers, $letters, $a); 
    
    echo $change; 
    
    ?>
    
    PHP:
     
    MyVodaFone, Nov 29, 2011 IP
  3. ironmankho

    ironmankho Active Member

    Messages:
    393
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    55
    #3
    Thanks for that ... it is what that i want
     
    ironmankho, Nov 29, 2011 IP