random letters order in word (quick help)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

Kieran Huggins wrote:NSG: Those are some niceforms ;-)
:wink:
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Post by spamyboy »

Kieran Huggins wrote:it works best when the ascenders and descenders are in the correct places as well

NSG: Those are some niceforms ;-)

Code: Select all

<?php
if($_POST['text']) {
$text=$_POST['text'];
$text = explode(" ", $text);
foreach( $text as $word )
{
$word_long=strlen($word)-2;
$first_letter=substr($word, 0, 1);
$random_letters=substr($word, 1, $word_long);
$random_letters=str_shuffle($random_letters);
$last_letter=substr($word, -1, 1);
$word=$first_letter.$random_letters.$last_letter;
$new_words[] = $word;
}
$text = implode(" ", $new_words);
echo $text;
}
?>
So could anyone help with this ?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

For it to be encoded, you would have to be able to decode it, wouldn't you?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

spamyboy, be patient! :evil:
User avatar
spamyboy
Forum Contributor
Posts: 266
Joined: Sun Nov 06, 2005 11:29 am
Location: Lithuania, vilnius

Post by spamyboy »

bump
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

make the word an array, copy the letters that have ascenders to one array, copy the letters that have descenders to another array, and copy the rest to a third array. Jumble each array, then replace them in the order you fetched them from: ascender over ascender, descender.... you get the picture.
Post Reply