This is quite a simple question, but I am finding it hard to find an answer.
I have a script that has the following:
I have seen
array() but never
(array). What does it do?
(array) will cast an object as an array
$item->classes->attribute_a = 1 and
$item->classes->attribute_b = 2,
$object_to_array = (array)$item->classes;
creates an associated array equivalent to
array('attribute_a' => 1, 'attribute_b' => 2).
Typecasting is not just for arrays, it works between many different types. For example an integer could be cast as a string;
$i = 123; $string_i = (string)$i;
Much more on typecasting here