Looking for php script!?

  • Thread starter Thread starter Rob M
  • Start date Start date
R

Rob M

Guest
i would first make an array of all the letters and the new letters like:
$arr = array('h' => 'o', 'e' => 'l');
for all the letters in the alphabet

then simply loop through their word and put the current character into your array to get the new character and append that onto a string

here you go, i wrote it up:
<?php
$message = "hello";
$decode = array('h' => 'o', 'e' => 'l', 'l' => 'i', 'o' => 'm');
$newMessage = "";

$message = str_split( $message );

foreach($message as $char) {
$newMessage .= $decode[$char];
}

echo $newMessage;
?>
 
Well im looking for a basic PHP script where you input a word and it will change the letters.

Like
h=o
e=l
l=i
o=m

and then when you input ''hello'' the ouput will be: ''oliim''
 
i would first make an array of all the letters and the new letters like:
$arr = array('h' => 'o', 'e' => 'l');
for all the letters in the alphabet

then simply loop through their word and put the current character into your array to get the new character and append that onto a string

here you go, i wrote it up:
<?php
$message = "hello";
$decode = array('h' => 'o', 'e' => 'l', 'l' => 'i', 'o' => 'm');
$newMessage = "";

$message = str_split( $message );

foreach($message as $char) {
$newMessage .= $decode[$char];
}

echo $newMessage;
?>
 
Back
Top