If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
in_array() check करता है कि value Array में exist करती है या नहीं। यह Boolean value true / false return करता है।
in_array ( mixed $needle , array $haystack , bool $strict = false );
तीन arguments accept करता है , जो इस प्रकार हैं-
mixed $value | required : $value , search value है जिसे Array में search करना है। search value mixed type की हो सकती है। यह case sensitive होती है।
mixed type का मतलब होता है , कि आप अपनी need के according किसी भी type (String , Boolean , Array , Class , Numeric) की value pass कर सकते हैं। यह जरूरी नहीं है कि कोई special type की value ही pass करें।
array $array | required : $array Array variable है , जिसमे दी गयी value search करनी है।
bool $strict = false | optional : Boolean value define करती है कि Array में search की जाने value के साथ - साथ type भी चेक होगा या नहीं। default value false set होती है , means सिर्फ value check होगी।
File : php_in_array.php
<?php
$os = array("Mac", "NT", false, "Linux");
if (in_array("Linux", $os))
echo "Got Linux";
/*now check with lower case*/
if (in_array("mac", $os))
echo "Got mac";
/*check value with it's type*/
if (in_array("false", $osm, true))
echo "Got false";
?>
Got Linux
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook