Skip to content

Instantly share code, notes, and snippets.

@drmmr763
Created April 22, 2013 20:24
Show Gist options
  • Save drmmr763/5438198 to your computer and use it in GitHub Desktop.
Save drmmr763/5438198 to your computer and use it in GitHub Desktop.
Little php based recursion function for putting together a list of folders in html.
<?php
/*
** recursive function which builds child / parent option list of
** select list options
*/
public function getSubfoldersList($parent_id)
{
$model = new BoxsearchModelBoxsearch();
$subfolders = $model->getSubFolders($parent_id);
$opts = '';
foreach($subfolders as $folder) {
$opts = '<option value="' . $folder->id . '"> . "-" ' . $folder->name . '</option>';
if ($model->getSubFolders($folder->id)) {
$opts .= getSubfoldersList($folder->id);
}
}
return $opts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment