Page 1 of 2

random letters order in word (quick help)

Posted: Tue Feb 27, 2007 1:43 pm
by spamyboy
Can't find way to make random letters order in word, for e.g. if string is apple so it should look like ~ "pleap".

Re: random letters order in word (quick help)

Posted: Tue Feb 27, 2007 1:50 pm
by visitor-Q
spamyboy wrote:Can't find way to make random letters order in word, for e.g. if string is apple so it should look like ~ "pleap".
did you try

Code: Select all

shuffle($string)

Posted: Tue Feb 27, 2007 1:51 pm
by Kieran Huggins
explode(), shuffle(), implode() ?

Posted: Tue Feb 27, 2007 1:52 pm
by spamyboy
thanks !

Posted: Tue Feb 27, 2007 1:52 pm
by pickle

Posted: Tue Feb 27, 2007 1:53 pm
by visitor-Q
wow that was a lot of posts in just a few seconds. quite a development of responses =)

Posted: Tue Feb 27, 2007 2:11 pm
by Kieran Huggins
you did ask for (quick help)... the default argument is (slow help)

Posted: Tue Feb 27, 2007 2:17 pm
by spamyboy
here is what I made:

Code: Select all

http://php-only.com/
,kinde of fun text encoding.

Posted: Tue Feb 27, 2007 2:18 pm
by spamyboy
If anyone whould help make it ajax, that would be wounderful.

Posted: Tue Feb 27, 2007 2:20 pm
by pickle
spamyboy wrote:here is what I made:

Code: Select all

http://php-only.com/
,kinde of fun text encoding.
spamyboy wrote: f anyone whould help make it ajax, that would be wounderful.

Um...what does that have to do with randomizing a word? If you need help on another topic, please make a new thread.

Posted: Tue Feb 27, 2007 2:22 pm
by Luke
nice looking form. bookmarked. :)

Posted: Tue Feb 27, 2007 2:27 pm
by spamyboy
pickle wrote:
spamyboy wrote:here is what I made:

Code: Select all

http://php-only.com/
,kinde of fun text encoding.
spamyboy wrote: f anyone whould help make it ajax, that would be wounderful.

Um...what does that have to do with randomizing a word? If you need help on another topic, please make a new thread.
Image
here is exaple of forum output. midle letters are randomized, lol, havent you noticed that :) ?

Posted: Tue Feb 27, 2007 2:32 pm
by pickle
I must admit, I didn't follow your link. I thought the phrase "http://php-only.com" was what you had made, not the webpage hosted there.

A pretty big brain fart on my part :oops: - sorry about that.

Posted: Tue Feb 27, 2007 2:33 pm
by Kieran Huggins
it works best when the ascenders and descenders are in the correct places as well

NSG: Those are some niceforms ;-)

Posted: Tue Feb 27, 2007 2:53 pm
by spamyboy
Kieran Huggins wrote:it works best when the ascenders and descenders are in the correct places as well
How can that be made ?

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