本文整理汇总了PHP中RecursiveIteratorIterator::hasChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP RecursiveIteratorIterator::hasChildren方法的具体用法?PHP RecursiveIteratorIterator::hasChildren怎么用?PHP RecursiveIteratorIterator::hasChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecursiveIteratorIterator
的用法示例。
在下文中一共展示了RecursiveIteratorIterator::hasChildren方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_folders
public function get_folders($directory)
{
$rows = array();
$iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory), true);
foreach ($iter as $file) {
if ($iter->hasChildren() && !strstr($iter->getPath() . "/" . $file, "/.")) {
$row['name'] = str_repeat(' ', $iter->getDepth()) . ucfirst(basename($file));
$row['path'] = $iter->getPath() . "/" . basename($file);
$rows[] = $row;
unset($row);
}
}
return $rows;
}
示例2: _restructure
protected function _restructure(array $params)
{
$output = [];
foreach ($params as $name => $array) {
foreach ($array as $field => $value) {
$pointer =& $output[$name];
if (!is_array($value)) {
$pointer[$field] = $value;
continue;
}
$stack = [&$pointer];
$iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($value), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $key => $value) {
array_splice($stack, $iterator->getDepth() + 1);
$pointer =& $stack[count($stack) - 1];
$pointer =& $pointer[$key];
$stack[] =& $pointer;
if (!$iterator->hasChildren()) {
$pointer[$field] = $value;
}
}
}
}
return $output;
}
示例3: CheckKaliInam
/**
* Check if the Prosody Metre is KalipaaInam - If the metre matches return
* the exact type, else return NULL
*
* @return Ambigous <string, NULL>
*/
public function CheckKaliInam()
{
$TaazhisaiCheck = TRUE;
$KattalaiCheck = FALSE;
$TuraiCheck = $this->CheckLineWordCount(4, 5);
$ViruttamCheck = $this->CheckLineWordCount(4, 4);
/* Check for Kattalai Kaliththurai */
if ($TuraiCheck) {
/*
* Check for Letter count in Each line
*/
$Lines = explode(PHP_EOL, trim($this->InputSourceText));
$LinesMetre = array();
$root = $this->ParseTreeRoot;
$rit = new RecursiveIteratorIterator(new RecursiveArrayIterator($root), RecursiveIteratorIterator::SELF_FIRST);
$NewSentence = TRUE;
foreach ($rit as $key => $value) {
if ($rit->hasChildren() === FALSE) {
if ($NewSentence) {
if ($key == "nE_r" || $key == "nirY") {
$LinesMetre[] = $key;
$NewSentence = FALSE;
}
}
} else {
if ($rit->getDepth() == 2) {
$NewSentence = TRUE;
}
}
}
$WordCountCheck = TRUE;
for ($LineIndex = 0; $LineIndex < count($Lines); $LineIndex++) {
$LetterCount = $this->GetLetterCount($Lines[$LineIndex]);
$KattalaiCount = $LetterCount['Vowel'] + $LetterCount['ConsonantVowel'];
// echo $KattalaiCount;
if ($LinesMetre[$LineIndex] == "nE_r" && $KattalaiCount != 16) {
$WordCountCheck = FALSE;
}
if ($LinesMetre[$LineIndex] == "nirY" && $KattalaiCount != 17) {
$WordCountCheck = FALSE;
}
}
/*
* Check for Vendalai in each line.. but not inbetween lines
*/
$WordBondClassCheck = TRUE;
$WCount = 1;
foreach ($this->WordBond as $Bond) {
$BondType = $Bond['bond'];
if ($WCount % 5 != 0) {
if (substr($BondType, strlen($BondType) - 21) != "வெண்டளை") {
$WordBondClassCheck = FALSE;
}
}
$WCount++;
}
/*
* Check if LastSyllableEnds with E
*/
$LastSyllableCheck = TRUE;
$LastSyllable = substr($this->InputSourceText, -1);
if ($LastSyllable != "E") {
$LastSyllableCheck = FALSE;
}
if ($WordBondClassCheck && $WordCountCheck && $LastSyllableCheck) {
$KattalaiCheck = TRUE;
}
}
/*
* Check for Kalittaazhisai
*/
if ($this->TotalLines < 2) {
$TaazhisaiCheck = FALSE;
}
$LineTypeReverse = array_flip($this->LineType);
$ProsodyLineTypes = $this->LineClass;
$LineWordCount = array();
foreach ($ProsodyLineTypes as $key => $value) {
if ($key + 1 != $this->TotalLines) {
$LineWordCount[] = $LineTypeReverse[$value];
} else {
$FinalLineCount = $LineTypeReverse[$value];
}
}
if (count($LineWordCount) > 0) {
if (max($LineWordCount) >= $FinalLineCount) {
$TaazhisaiCheck = FALSE;
}
}
if ($TaazhisaiCheck) {
$MetreType = "kali_ttAZicY";
} else {
if ($KattalaiCheck) {
$MetreType = "ka_TTaLY kali_ttuRY";
//.........这里部分代码省略.........
示例4: __construct
/**
* Constructs a new instance of HTTPRequest.
*
* @param string $url URL to connect to
* @param array<string> $options
* @param mixed $postParameters Parameters to send via POST
* @param array $files Files to attach to the request
*/
public function __construct($url, array $options = array(), $postParameters = array(), array $files = array())
{
$this->setURL($url);
$this->postParameters = $postParameters;
$this->files = $files;
$this->setOptions($options);
// set default headers
$this->addHeader('user-agent', "HTTP.PHP (HTTPRequest.class.php; WoltLab Community Framework/" . WCF_VERSION . "; " . WCF::getLanguage()->languageCode . ")");
$this->addHeader('accept', '*/*');
$this->addHeader('accept-language', WCF::getLanguage()->getFixedLanguageCode());
if (isset($this->options['maxLength'])) {
$this->addHeader('Range', 'bytes=0-' . ($this->options['maxLength'] - 1));
}
if ($this->options['method'] !== 'GET') {
if (empty($this->files)) {
if (is_array($postParameters)) {
$this->body = http_build_query($this->postParameters, '', '&');
} else {
if (is_string($postParameters) && !empty($postParameters)) {
$this->body = $postParameters;
}
}
$this->addHeader('content-type', 'application/x-www-form-urlencoded');
} else {
$boundary = StringUtil::getRandomID();
$this->addHeader('content-type', 'multipart/form-data; boundary=' . $boundary);
// source of the iterators: http://stackoverflow.com/a/7623716/782822
if (!empty($this->postParameters)) {
$iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->postParameters), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $k => $v) {
if (!$iterator->hasChildren()) {
$key = '';
for ($i = 0, $max = $iterator->getDepth(); $i <= $max; $i++) {
if ($i === 0) {
$key .= $iterator->getSubIterator($i)->key();
} else {
$key .= '[' . $iterator->getSubIterator($i)->key() . ']';
}
}
$this->body .= "--" . $boundary . "\r\n";
$this->body .= 'Content-Disposition: form-data; name="' . $key . '"' . "\r\n\r\n";
$this->body .= $v . "\r\n";
}
}
}
$iterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($this->files), \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $k => $v) {
if (!$iterator->hasChildren()) {
$key = '';
for ($i = 0, $max = $iterator->getDepth(); $i <= $max; $i++) {
if ($i === 0) {
$key .= $iterator->getSubIterator($i)->key();
} else {
$key .= '[' . $iterator->getSubIterator($i)->key() . ']';
}
}
$this->body .= "--" . $boundary . "\r\n";
$this->body .= 'Content-Disposition: form-data; name="' . $k . '"; filename="' . basename($v) . '"' . "\r\n";
$this->body .= 'Content-Type: ' . (FileUtil::getMimeType($v) ?: 'application/octet-stream.') . "\r\n\r\n";
$this->body .= file_get_contents($v) . "\r\n";
}
}
$this->body .= "--" . $boundary . "--";
}
$this->addHeader('content-length', strlen($this->body));
}
if (isset($this->options['auth'])) {
$this->addHeader('authorization', "Basic " . base64_encode($options['auth']['username'] . ":" . $options['auth']['password']));
}
$this->addHeader('connection', 'Close');
}
示例5: abs
// set the current depth
$curDepth = $it->getDepth();
// store the difference in depths
$diff = abs($curDepth - $depth);
// close previous nested levels
if ($curDepth < $depth) {
$output->append(str_repeat('</ul></li>', $diff));
}
// check if we have the last nav item
if ($it->hasNext()) {
$output->append('<li><a href="' . $url . '">' . $name . '</a>');
} else {
$output->append('<li class="last"><a href="' . $url . '">' . $name . '</a>');
}
// either add a subnav or close the list item
if ($it->hasChildren()) {
$output->append('<ul>');
} else {
$output->append('</li>');
}
// cache the depth
$depth = $curDepth;
}
// if we have values, output the unordered list
if ($output->count()) {
echo '<ul id="nav">' . "\n" . implode("\n", (array) $output) . "\n" . '</ul>';
}
} catch (Exception $e) {
die($e->getMessage());
}
echo PHP_EOL . PHP_EOL . 'CLASS EXAMPLE' . PHP_EOL . PHP_EOL;