note 129325 added to function.file

From: Date: Sat, 09 Mar 2024 20:05:30 +0000
Subject: note 129325 added to function.file
Groups: php.notes 
Request: Send a blank email to php-notes+get-221239@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 = $getWords[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/129325 Del: integrated -- https://main.php.net/note/delete/129325/integrated Del: useless -- https://main.php.net/note/delete/129325/useless Del: bad code -- https://main.php.net/note/delete/129325/bad+code Del: spam -- https://main.php.net/note/delete/129325/spam Del: non-english -- https://main.php.net/note/delete/129325/non-english Del: in docs -- https://main.php.net/note/delete/129325/in+docs Del: other reasons-- https://main.php.net/note/delete/129325 Reject -- https://main.php.net/note/reject/129325 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221239) next »