- array_column: documentation ( source)
- token_get_all: documentation ( source)
<?php
$string = <<<STRING
what is "this <? echo str_replace(':'," '', 'cool');
STRING;
foreach (array_column(token_get_all($string), 1) as $token) {
echo $token, PHP_EOL;
}