ArrayObject offsetSet () Function in PHP

👻 See our latest reviews to choose the best laptop for Machine Learning and Deep learning tasks!

Syntax :
void offsetSet ($index, $val)
Parameters : This function takes two parameters $index and $val. This function updates the value present in the index, $index with $val.Return value : This function does not return no value.The following programs illustrate the above function:Program 1 :
// PHP illustration program
// offsetSet() function $arr = array ( " engineer100 " , "engineer99" , "engineer1 " , " engineer02 " );
// Create array object $arrObject = new ArrayObject ( $arr );
// Update the value at index 1 $arrObject -> offsetSet (1, "Updated" );
// Print the updated ArrayObject print_r ( $arrObject );
?>
Exit:
ArrayObject Object ( [storage: ArrayObject: private] = > Array ([0] = > engineer100 [1] = > Updated [2] = > engineer1 [3] = > engineer02))
Program 2 :
// PHP -program for illustration
// offsetSet() function $arr = array ( "Welcome" = > "1 " , " to " = > "2" , "GfG" = > "3" );
// Create array object $arrObject = new ArrayObject ( $arr );
// Update the value by index "to" $arrObject -> offsetSet ( "to" , "UpdatedValue" );
// Print the updated ArrayObject print_r ( $arrObject );
?>
Exit:
ArrayObject Object ( [storage: ArrayObject: private] = > Array ([Welcome] = > 1 [to] = > UpdatedValue [GfG] = > 3))
Link: http://php.net/manual/en/arrayobject.offsetset.php

👻 Read also: what is the best laptop for engineering students in 2022?

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

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