note 126379 deleted from function.file by salathe

From: Date: Wed, 01 Sep 2021 15:56:25 +0000
Subject: note 126379 deleted from function.file by salathe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-216848@lists.php.net to get a copy of this message
Note Submitter: honza dot stech at gmail dot com ---- Keep in mind that file() will NOT trim the new line characters at the end of the lines. The means, that for example this code will always output "No bad words detected": <?php $badWords = file('badwords.txt'); /* badwords.txt file contents: love lust sex */ $comment = "I love PHP!"; foreach ($badWords as $badWord) { if (mb_stripos($comment, $badWord)) { exit("Don't use naughty words"); } } echo "No bad words detected";

« previous php.notes (#216848) next »