note 129324 added to function.file
| From: | Phrebbie | Date: | Sat, 09 Mar 2024 20:05:12 +0000 |
| Subject: | note 129324 added to function.file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-221240@lists.php.net to get a copy of this message | ||
I was looking for a way to get a random word from a list of words fetched from a .txt file in PHP
and this works just as expected. Each word in the file is separated by a new line. Hope this helps
someone.
$getWords = file("list_of_words.txt");
$word = $getContent[rand(0, count($getWords) - 1)];
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.13.131 (proxied: 83.252.52.233)
----
Manual Page -- https://php.net/manual/en/function.file.php
Edit -- https://main.php.net/note/edit/129324
Del: integrated -- https://main.php.net/note/delete/129324/integrated
Del: useless -- https://main.php.net/note/delete/129324/useless
Del: bad code -- https://main.php.net/note/delete/129324/bad+code
Del: spam -- https://main.php.net/note/delete/129324/spam
Del: non-english -- https://main.php.net/note/delete/129324/non-english
Del: in docs -- https://main.php.net/note/delete/129324/in+docs
Del: other reasons-- https://main.php.net/note/delete/129324
Reject -- https://main.php.net/note/reject/129324
Search -- https://main.php.net/manage/user-notes.php