note 126554 added to function.in-array
| From: | davide dot iandoliatfattura24 dot com at main dot php dot net | Date: | Wed, 03 Nov 2021 11:59:33 +0000 |
| Subject: | note 126554 added to function.in-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217137@lists.php.net to get a copy of this message | ||
I tried to use in_array in combination with array_colum, here below a sample:
<?php
$customArray = [
array('name' => 'test',
'is_gift' => true,
'reduction' => 10.0),
array('name' => 'test2',
'is_gift' => false,
'reduction' => 5.0)
];
$is_gift = in_array(true, array_column($customArray, 'is_gift'));
var_dump($is_gift);
?>
Result:
bool(true)
It seems to work right
----
Server IP: 45.112.84.4
Probable Submitter: 45.112.85.242 (proxied: 87.11.225.86)
----
Manual Page -- https://php.net/manual/en/function.in-array.php
Edit -- https://main.php.net/note/edit/126554
Del: integrated -- https://main.php.net/note/delete/126554/integrated
Del: useless -- https://main.php.net/note/delete/126554/useless
Del: bad code -- https://main.php.net/note/delete/126554/bad+code
Del: spam -- https://main.php.net/note/delete/126554/spam
Del: non-english -- https://main.php.net/note/delete/126554/non-english
Del: in docs -- https://main.php.net/note/delete/126554/in+docs
Del: other reasons-- https://main.php.net/note/delete/126554
Reject -- https://main.php.net/note/reject/126554
Search -- https://main.php.net/manage/user-notes.php