- array_column: documentation ( source)
- print_r: documentation ( source)
<?php
$o = new stdClass;
$o->text = "ans1";
$o2 = new stdClass;
$o2->text = "ans2";
$o3 = new stdClass;
$o3->text = "ans3";
$arr = [$o, $o2, $o3];
$array = array_column($array, 'text');
print_r($array);