Jump to content


Photo

Cut-up engine


  • Please log in to reply
9 replies to this topic

#1 sano

sano
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 October 2006 - 01:50 PM

Hi,

Im trying to create a cut-up engine, re-arranging a text input to spit out a different text on the output.


I need a basic idea on what i need todo. Can anyone help me? I have basic php knowledge but im stumped  :(

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 15 October 2006 - 01:57 PM

I have no idea what it is you're hoping to do, but the substr() function might be part of the solution.

http://ca.php.net/ma...tion.substr.php
Legend has it that reading the manual never killed anyone.
My site

#3 sano

sano
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 October 2006 - 02:10 PM

Thanks, im looking at this now.

Im trying to create an engine that jumbles up words to create a new phrase. (or even new words!) So you type a phrase an it jumbles it into a new phrase!

so it could involve a random function ??? im not too sure tho. Thanks anyway!



#4 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 15 October 2006 - 02:42 PM

You mean a program that creates anagrams.
Do they have to be meaningful (a word) or just a random mix up?

If you are looking only for a random mix up, you can just use the function str_shuffle().
But if you want to make in words out of the inputed word, it's a bit more complicated but I got an idea how to do.

Orio.
Think you're smarty?

(Gone until 20 to November)

#5 sano

sano
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 October 2006 - 03:18 PM

I mean creating a new phrase from an input phrase.

Its for creating obscure lyrics and litrature. 


for example,

input: The farmer planted a tree in the forest

output: Planted the tree in the forest a farmer  (silly example i know, but you get the point!)  ;D

Thanks.

#6 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 15 October 2006 - 03:21 PM

Do you want only to change the word's places, or change the letters themselves too (like in this site).

Orio.
Think you're smarty?

(Gone until 20 to November)

#7 sano

sano
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 October 2006 - 03:25 PM

Well im trying to keep it simple to just the word places for now.

Il try an deal with letters later.  :-\


Sano



#8 sano

sano
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 October 2006 - 05:45 PM

Can anyone give me some advice on where to start with this?  (what i need to use?)

I want to create a word scrambler that changes the words in a sentance around randomly.


thanks in advance.




#9 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 15 October 2006 - 06:02 PM

First, you recieve the variable from a form (let's say the method you used is post, and the field's name was "words"):
$string=$_POST['words'];

Then you split it into an array using explode() (by spaces):
$words=explode(" ", $string);

Then you use shuffle() to randomize the order:
shuffle($words);

Then you use implode() to join back the elements, using the glue as space:
$result=implode(" ",$words);

Finally, print the result:
echo $result;



Whole code looks like this:
<?php

$string=$_POST['words'];

$words=explode(" ", $string);
shuffle($words);
$result=implode(" ",$words);

echo $result;

?>


Hope it helps :)


Orio.
Think you're smarty?

(Gone until 20 to November)

#10 sano

sano
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 15 October 2006 - 06:25 PM

wow, thanks orio, great help!  ;D ;D


i found this which is what im trying to make.

http://www.richkni.c...p/text/text.php

this is more complex tho  :P





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users