本文整理汇总了PHP中Arr::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::first方法的具体用法?PHP Arr::first怎么用?PHP Arr::first使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::first方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run($bRemoveComment = true)
{
$sCurrentLine = '';
$aInstructionList = array();
foreach (preg_split("/((\r?\n)|(\r\n?))/", $this->sSelectedContent) as $line) {
if (empty($line) || !Arr::in($this->nonAtom, substr($line, 0, 1))) {
continue;
} else {
if ($bRemoveComment && strpos($line, ';') !== false) {
$sCurrentLine .= strstr($line, ';', true);
if (empty($sCurrentLine)) {
continue;
}
} else {
$sCurrentLine .= $line;
}
}
if (substr_count($sCurrentLine, '(') !== substr_count($sCurrentLine, ')')) {
continue;
}
try {
// Util::var_dump($this->tokenize(trim($sCurrentLine))); echo '<br /><br />';
$aResult = $this->parse($this->tokenize(trim($sCurrentLine)));
$aInstructionList[] = count($aResult) === 1 ? Arr::first($aResult) : $aResult;
} catch (Exception $e) {
echo 'Exception for : ' . '<br />';
Util::var_dump($sCurrentLine);
}
$sCurrentLine = '';
}
return $aInstructionList;
}
示例2: loadConfiguration
public static function loadConfiguration($sKey)
{
$aSegment = explode('.', $sKey);
if (Arr::size($aSegment) > 0) {
$sConfigName = Arr::first($aSegment);
if (!isset(self::$aConfiguration[$sConfigName])) {
self::initConfiguration();
$aTmpConfig = array();
// Common config
$sCommonConfigPath = self::$sRealRootPath . RELATIVE_PATH_ROOT_TO_CONFIG . FOLDER_CONFIG_GLOBAL . $sConfigName . '.php';
if (Filesystem::exists($sCommonConfigPath)) {
$aTmpConfig = (require $sCommonConfigPath);
}
// Env config
$sCurrentEnvironment = self::getEnvironment();
$sConfigEnvironmentPath = self::$sRealRootPath . RELATIVE_PATH_ROOT_TO_CONFIG . $sCurrentEnvironment . '/' . $sConfigName . '.php';
if (Filesystem::exists($sConfigEnvironmentPath)) {
$aTmpConfig = array_merge($aTmpConfig, require $sConfigEnvironmentPath);
}
self::$aConfiguration[$sConfigName] = $aTmpConfig;
}
}
}
示例3: array_first
/**
* Return the first element in an array passing a given truth test.
*
* @param array $array
* @param \Closure $callback
* @param mixed $default
* @return mixed
*/
function array_first($array, $callback, $default = null)
{
return Arr::first($array, $callback, $default);
}
示例4: first
/**
* Get the first item from the collection.
*
* @param callable|null $callback
* @param mixed $default
* @return mixed
*/
public function first(callable $callback = null, $default = null)
{
return Arr::first($this->items, $callback, $default);
}