note 127048 added to function.mb-stristr

From: Date: Wed, 11 May 2022 21:04:10 +0000
Subject: note 127048 added to function.mb-stristr
Groups: php.notes 
Request: Send a blank email to php-notes+get-218372@lists.php.net to get a copy of this message
Be aware that if needle is an empty string, mb_stristr return the haystack by default. For exemple: <?php if (mb_stristr("foo", "")) { echo "We enter in condition"; } ?> Because in the above exemple the return of mb_stristr is "foo". So if we do not want this kind of behaviour, we must set the third argument, ($before_needle) to true. <?php if (mb_stristr("foo", "", true)) { echo "We do not enter in condition"; } ?> It can be useful to know it, specially when needle is dynamic. ---- Server IP: 45.112.84.4 Probable Submitter: 185.85.3.47 (proxied: 81.67.121.67) ---- Manual Page -- https://php.net/manual/en/function.mb-stristr.php Edit -- https://main.php.net/note/edit/127048 Del: integrated -- https://main.php.net/note/delete/127048/integrated Del: useless -- https://main.php.net/note/delete/127048/useless Del: bad code -- https://main.php.net/note/delete/127048/bad+code Del: spam -- https://main.php.net/note/delete/127048/spam Del: non-english -- https://main.php.net/note/delete/127048/non-english Del: in docs -- https://main.php.net/note/delete/127048/in+docs Del: other reasons-- https://main.php.net/note/delete/127048 Reject -- https://main.php.net/note/reject/127048 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218372) next »