Re: pharse file random work with -n lines
| From: | Marek Kilimajer | Date: | Tue, 04 Mar 2003 16:25:03 +0000 |
| Subject: | Re: pharse file random work with -n lines | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-138128@lists.php.net to get a copy of this message | ||
Sorry, I forgot about the random part. Append the lines to an array, and then use array_rand:
while($tmp= fgetcsv($fp,50000,"\|")) { $array[]=$tmp; }
$rand_array=array_rand($array, 10);
WebDev wrote:
Yes it works here only this way "\|" but I have not figuered it to return it random ----- Original Message ----- From: Marek Kilimajer <kilimajer@webglobe.sk> To: WebDev <WebDev@browseabit.com> Cc: <php-general@lists.php.net> Sent: Tuesday, March 04, 2003 5:00 AM Subject: Re: [PHP] pharse file random work with -n lineswhile(list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,$vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = fgetcsv ($fp,50000,"\|") {// here you can do what you need to do } are you sure you want "\|" and not "|"? WebDev wrote:info careeners and do something with it ....how can you return this randomized? how can I get every time I call this function a random set of lines ? Working Code to read 10 first lines and split the individual line into("../../../../../public/httpd/html/datacontainer/data/storage.data", "r");.... $i = 0; $fp = fopen$vier, $usern, $locst, $locstaa, $locc, $funf, $sech, $email, $Url, $ClassCat, $ClassCat2, $Headstart, $Headend, $Descrip, $End1, $Endzwei, $End3, $Endvier, $Endfunf, $Endsech, $Endsieben, $Endacht, $Endne, $dreizwei, $dreidrei, $dreivier, $dreifunf, $dreisechs ) = split ("\|", $buffer);while (!feof ($fp) && $i < 10) { $i++; $buffer = fgets($fp, 4096); list ($adnr, $user, $date, $listed, $hlong, $eins, $zwei, $drei,\\ do something } fclose ($fp);