if($DBObj->fetchNumOfRows() >= 1){
$queryRecords = $DBObj->fetchAllRecordsArray();
$rows = $DBObj->fetchNumOfRows();
for($i = 0; $i < $rows; $i++){
recursiveAction($queryRecords[$i]);
}
}
function recursiveAction(&$item, $propertiesArray) {
switch ($item['propof']) {
case 'page':
// No need for that "if" check
$propertiesArray[$item['propofid']][] = [$item['propid'] => $item['propvalue'],'proplinkedto' => $item['proplinkedto']];
break;
case 'object':
$DBObj->querySelect(...);
$queryRecord = $DBObj->fetchNumOfRows() == 1 ? $DBObj->fetchRecordArray() : "";
if (!empty($queryRecord)) {
// Here we convert common part of "object" into recursion
recursiveAction($queryRecord);
}
break;
case 'element':
...
}
}