本文整理匯總了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);
}