RE: [PHP] Array of words in textfile?

From: Date: Fri, 06 Apr 2001 21:22:26 +0000
Subject: RE: [PHP] Array of words in textfile?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-47507@lists.php.net to get a copy of this message
If you're splitting by a defined pattern (such as a space " ") explode is quite a bit faster...and i believe that if you need reg exps. you can use split() (which will take a regex as the pattern)... -js > -----Original Message----- > From: Plutarck [mailto:aemuli@spamclause-yahoo.com] > Sent: Thursday, April 05, 2001 11:11 PM > To: php-general@lists.php.net > Subject: Re: [PHP] Array of words in textfile? > > > If they are all in a format like that, first just read the text file with > fopen/fread into one big string. > > Then use: > > $refined_string = explode(" ", $bigstring); > > That's the main way to do it, but the preferable way is using a regular > expression with either the ereg or preg functions. > > > -- > Plutarck > Should be working on something... > ....but forgot what it was. > > > "Jan Grafström" <jan@lillemanshus.com> wrote in message > news:3ACD5AF2.D8D3B254@lillemanshus.com... > > Hi! > > I want to read a textfile (cat, dog, rat,) and get it like this: > > $namesArray = array("cat,", "dog,", "rat,"); > > If I can do this than I can go on and make changes in my array. > > Like the examples in php manual. > > > > > > Thanks in advance for any tips. > > > > Regards > > Jan > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > >

« previous php.general (#47507) next »