How can one access and retrieve data from an array/ object in PHP?

To access and retrieve data from an array/object in PHP, you can use square brackets for arrays and -> for objects. Simply specify the key or property name within the brackets or after the -> to retrieve the desired data. Example PHP code snippet:

// Accessing data from an array
$array = array("key1" => "value1", "key2" => "value2");
echo $array["key1"]; // Output: value1

// Accessing data from an object
$obj = (object) ["property1" => "value1", "property2" => "value2"];
echo $obj->property2; // Output: value2