In what case is it more applicable to use:
$Obj_Array = new ArrayObject(array(), ArrayObject::STD_PROP_LIST);
$Obj_Array->Key = "Value";
Rather:
$Array = array();
$Array['Key'] = "Value";
Now, these are both different. I can tell that far, even know after performing research I see no real reason to have a preference on object arrays over traditional arrays..
So Could someone Show me an active example on how object arrays provide more benefit over a normal array
In addition, i'm aware that these object arrays are fairly new to PHP.. But nearly all database functions for example, returns either an array or single variables:
$Query = $DB->prepare("SELECT * FROM TBL WHERE col=?");
$Query->bind_param('s',$Variable);
$Query->execute();
$Query->bind_result($Col1, $Col2, $Col3);
$Query->fetch();
$Query->close();
The above example returns the contents as singe variables.
So to create an object array using a while loop:
$Obj_Array = new ArrayObject(array(), ArrayObject::STD_PROP_LIST);
$Key_Creation = 0;
$Query = $DB->prepare("SELECT Username,Password FROM TBL WHERE col=?");
$Query->bind_param('s',$Variable);
$Query->execute();
$Query->bind_result($Col1, $Col2);
while($Query->fetch()){
$Obj_Array->$Key_Creation = array($Col1,$Col2);
$Key_Creation++;
}
$Query->close();