本文整理汇总了PHP中Arr::join方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::join方法的具体用法?PHP Arr::join怎么用?PHP Arr::join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::join方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: scan
public static function scan($path, $recursive = true, $excludeDir = true)
{
$path = self::formatPath($path);
$dh = opendir($path);
if (!$dh) {
return [];
}
$files = [];
while (false !== ($file = readdir($dh))) {
if ($file == '.' || $file == '..') {
continue;
}
$fileType = filetype($path . $file);
if ('file' == $fileType) {
$files[] = $path . $file;
}
if ('dir' == $fileType) {
if (true === $recursive) {
$innerFiles = Dir::scan($path . $file . '/', $recursive, $excludeDir);
$files = Arr::join($files, $innerFiles);
}
if (false === $excludeDir) {
$files[] = $path . $file . '/';
}
}
}
closedir($dh);
return $files;
}
示例2: Arr
// output: This NUMBER word sentence is less than NUMBER letters long.
echo $b->replace("/([0-9]+)/", 'NUMBER', true) . "\n";
// not using regular expressions, and lowercase
// output: this9wordsentenceislessthan1000letterslong.
echo $b->replace(' ', '')->toLower() . "\n";
// something a bit more complex
// strips the trailing 0's and 9's and splits it into an array, adds an element, reverse sorts it and turns it into an array
// output:
/*
Array
(
[8] => hi there!
[7] => 8
[6] => 7
[5] => 6
[4] => 5
[3] => 4
[2] => 3
[1] => 2
[0] => 1
)
*/
print_r($a->rtrim('09')->split()->push('hi there!')->rsort()->toArray());
// turning a standard array into a special array
$c = new Arr(array('hi', 'there', 'how', 'are', 'you?'));
// output: hi there how are you?
echo $c->join(' ') . "\n";
// you can still use the String class like an array:
$d = new String('012345');
// output: string(1) "3"
var_dump($d[3]);