Jump to content


Photo

One problem fixed, and now another! Pls help!


  • Please log in to reply
No replies to this topic

#1 Pipes

Pipes
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 08 October 2006 - 08:01 PM

I know this is probably a hugely simple thing for an experienced programmer to see, but I'm just not at the moment...basically I've got a file of quotes that are split in the .txt file as so:

"Quote in quotations then" - Author <<<<<

I would like to write a script that splits the authors from the quotes. Here is where I'm at:

$quotesfile = "http://localhost/projects/quotes_list/quotes.txt";
$handle = fopen($quotesfile, 'rb');
$quotes = fread($handle, 1024);
$pattern = '/\"[A-Za-z0-9]\"/';
$quotes = preg_split($pattern, $quotes);
print_r($quotes);

This prints out as follows:
Array ( [0] => "We're going to go pull the call girl cards out of phone boxes." - Lisa Pruden "I think I left lippy on you." - Olga Bof "In the end I just pretended to take it, and then spat it out later" - Sasha Breslau "He likes a bit of chav." - Lauren Dunn "She responds well to Toblerone." - Stephen Hardingham "Everything in the world is on my little pink stick." - Jon Holmes "I'm not sure I want a wanking cat on a Friday afternoon." - Dom Eames "I like the idea of extreme cunninglingus." - Mandy Pollard "I'm trying to think of a retort to say I've got a huge cock, but I can't." - Scott Dingley "It's a man's place Lelia. It's supposed to be dirty." - Jon Salt "Do you want me to sit on you?" - Emma Williams "I don't dream about badgers." - Mark Limb "Did no-one see I just punched that girl? I feel like a wife beater." - Jon Salt The quotes list says goodbye to Paul "temple of meat" Sigaloff. Here are Paul's best bits: "I have to manage my own expectations." "Ok good - let's have a meeting, but don't )

I have tried a couple variations of a while and foreach loop, but each time I try one, I get no results at all. Either I get :

Array ( [0] => )

or there are no results whatever.

Can anyone let me know how to use the preg_split better so as to store the quotes and authors into the keys and values of an array, so that I can work with them more easily?

Any advice greatly appreciated!  :-\

Andy




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users