note 127007 added to function.str-contains

From: Date: Sat, 23 Apr 2022 20:36:49 +0000
Subject: note 127007 added to function.str-contains
Groups: php.notes 
Request: Send a blank email to php-notes+get-218308@lists.php.net to get a copy of this message
private function contains(array $needles, string $type, string $haystack = NULL, string $filename = NULL) : bool { if (empty($needles)) return FALSE; if ($filename) $haystack = file_get_contents($filename); $now_what = function(string $needle) use ($haystack, $type) : array { $has_needle = str_contains($haystack, $needle); if ($type === 'any' && $has_needle) return ['done' => TRUE, 'return' => TRUE]; if ($type === 'all' && !$has_needle) return ['done' => TRUE, 'return' => FALSE]; return ['done' => FALSE]; }; foreach ($needles as $needle) { $check = $now_what($needle); if ($check['done']) return $check['return']; } return TRUE; } function containsAny(array $needles, string $haystack = NULL, string $filename = NULL) : bool { return self::contains($needles, 'any', $haystack, $filename); } function containsAll(array $needles, string $haystack = NULL, string $filename = NULL) : bool { return self::contains($needles, 'all', $haystack, $filename); } ---- Server IP: 45.112.84.4 Probable Submitter: 80.90.5.135 (proxied: 189.92.219.119) ---- Manual Page -- https://php.net/manual/en/function.str-contains.php Edit -- https://main.php.net/note/edit/127007 Del: integrated -- https://main.php.net/note/delete/127007/integrated Del: useless -- https://main.php.net/note/delete/127007/useless Del: bad code -- https://main.php.net/note/delete/127007/bad+code Del: spam -- https://main.php.net/note/delete/127007/spam Del: non-english -- https://main.php.net/note/delete/127007/non-english Del: in docs -- https://main.php.net/note/delete/127007/in+docs Del: other reasons-- https://main.php.net/note/delete/127007 Reject -- https://main.php.net/note/reject/127007 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#218308) next »