Must be something simple, but I have been struggling with this for a while. I have PHP array
//Have array $arr which contains values from database
$createdAtArray=array();
foreach($arr as $value){
$idToMatch = $value['id'];
$dateToCompare = $value['createdAt']->format('F j Y, g:i');
array_push($createdAtArray,$dateToCompare,$idToMatch);
}
Now to check how my array looks i use
echo '<pre>'; print_r($createdAtArray); echo '</pre>';
var_dump($createdAtArray);
So I try to access my arrays value like this : $createdAtArray[0] and except to get January 1 2019, 12:00 but instead I get 'J' (First Letter in string)
After trying multiple options I found out that by accessing just $createdAtArray I get January 1, 2019, 12:00.
However I cant get values that I want. What am I doing wrong?

array_push($createdAtArray,array($dateToCompare,$idToMatch));. check and then print your array and iterate accordingly.