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;
?>
$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;
?>