ArrayObject offsetExists () Function in PHP

Syntax :
bool offsetExists ($index)
Parameters : This function takes one parameter $index, which is the index to check if present in the ArrayObject.Return Value : This function returns a Boolean value True or False depending on whether whether there is an index in the ArrayObject or not.The programs below illustrate the above function:Program 1 :
// PHP illustration program
// offsetExists() function $arr = array ( " engineer100 " , " engineer99 " , "engineer1" , "engineer02" );
// Create array object $arrObject = new ArrayObject ( $arr );
// Print ArrayObject print_r ( $arrObject );
// Check for key 1 if ( $arrObject -> offsetExists (1)) echo "The key 1 is present!" ; else echo " The key 1 is not present! " ;
// Check for key 20 if ( $arrObject -> offsetExists (20)) echo "The key 20 is present!" ; else echo " The key 20 is not present! " ;
?>
Exit:
ArrayObject Object ( [storage: ArrayObject: private] = > Array ([0] = > engineer100 [1] = > engineer99 [2] = > engineer1 [3] = > engineer02)) The key 1 is present! The key 20 is not present!
Program 2 :
// PHP illustration program
// offsetExists() function $arr = array ( "Welcome" = > "1" , "to" = > "2" , "GfG" = > "3" );
// Create array object $arrObject = new ArrayObject ( $arr );
// Print ArrayObject print_r ( $arrObject );
// Check for the "Welcome" key if ( $arrObject -> offsetExists ( "Welcome" )) echo "The key Welcome is present!" ; else echo " The key Welcome is not present! " ;
// Check for a GfG key if ( $arrObject -> offsetExists ( "GfG" )) echo "The key GfG is present!" ; else echo " The key GfG is not present! " ;
?>
Exit:
ArrayObject Object ( [storage: ArrayObject: private] = > Array ([Welcome] = > 1 [to] = > 2 [GfG] = > 3)) The key Welcome is present! The key GfG is present!
Link : http: // php. net / manual / en / arrayobject.offsetexists.php

Shop

Best laptop for Sims 4

$

Best laptop for Zoom

$499

Best laptop for Minecraft

$590

Best laptop for engineering student

$

Best laptop for development

$

Best laptop for Cricut Maker

$

Best laptop for hacking

$890

Best laptop for Machine Learning

$950

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method