Skip to content

Instantly share code, notes, and snippets.

View shiki's full-sized avatar

Jayson Basañes shiki

View GitHub Profile
#!/usr/bin/env php
<?php
/*
Copyright 2013 Stuart Carnie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
@shiki
shiki / gist:1408295
Created November 30, 2011 07:01 — forked from ferower/gist:1408279
public static function getSubTopicIdsOfTopic($topicId, &$topics = null)
{
$list = array();
if (empty($topics))
$topics = PTopic::model()->findAll();
foreach ($topics as $key => $topic) {
if ($topic->parentId == $topicId) {
$list[] = $topic->id;
$list = array_merge($list, self::getSubTopicIdsOfTopic($topic->id, $topics));
}