Fatal error: [] operator not supported for strings の対処方法

<?php
foreach($results as $key => $row) {
    $post_type[] = $row->post_type;
    $post_parent[] = $row->post_parent;
}
?>

こんな感じで配列にプッシュしていくコードを書いていると、
上記のエラーが出る場合があるが、
変数を配列として初期化することで解決する

<?php
$post_type = array();
$post_parent = array();
foreach($results as $key => $row) {
    $post_type[] = $row->post_type;
    $post_parent[] = $row->post_parent;
}
?>