Re: [PHP] Multiple words str_shuffle



On 7/6/08, Ron Piggott <ron.php@xxxxxxxxxxxxxxxxxx> wrote:


I am trying to scramble individual words and/or phrases.

When it is a phrase I would like to keep the letters of each word
together, with a space between each one. The code I have so far is
below. I use PHP 4.4.7. The code below is fine for a single word; it
is phrases that I am now trying to accommodate.


An example:

rise and shine

Desired output:

I S R E N A D E H I S N

Thanks for your help,

Ron



$keyword might be

$keyword = str_shuffle(strtoupper($keyword));

$buffer = "";

for ($count = 0; ($count < strlen($keyword)); $count++) $buffer .=
$keyword{$count}." ";

$keyword = trim($buffer);

unset($buffer);


Once the individual words have had their letters shuffled, explode the
sentence on a space, then use the shuffle function (
http://us3.php.net/manual/en/function.shuffle.php) to, um, shuffle the
array.

David


Relevant Pages

  • Re: Article <-> Section
    ... Same there in America: cheek-by-jowl is the standard. ... I admit to having no difficulty identifying with the language usage ... thereby denying that phrases are part of ... "vocabulary consists of a list of individual words but not of stock ...
    (alt.usage.english)
  • Re: Ive got a feeling: More on NI tagging a noun in front of a noun.
    ... Only a general outline can be here given; ... # constructions with individual words must be looked for under the words ... # I. Local position. ... in such phrases as 'at all costs', 'at full speed' or 'he went on at ...
    (sci.lang.japan)
  • Re: Querying words instead of phrases
    ... My website's search function looks up entire phrases instead of ... individual words. ... For example, if I query "Google Groups," I would ... You could split the search phrase by spaces, then query each word ...
    (comp.lang.javascript)
  • Re: Computerised authorship attribution
    ... John Uebersax wrote: ... Besides individual words, you might wish to look at some pairs of ... > words or short phrases that may reliably discriminate authorship. ... When I did experiments on phrases, ...
    (sci.stat.math)