本文整理汇总了PHP中to_array函数的典型用法代码示例。如果您正苦于以下问题:PHP to_array函数的具体用法?PHP to_array怎么用?PHP to_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_array函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Ethna_Container constructor.
* @param $directory (absolute)
*/
public function __construct(string $base, array $directory, array $class, string $appid, $locale, $sessionName)
{
$this->base = $base;
$this->class = $class;
$this->appid = $appid;
$this->locale = $locale;
$this->sessionName = $sessionName;
/**
* ディレクトリ設定を絶対パスに変換
*/
// ディレクトリ名の設定(相対パス->絶対パス)
foreach ($directory as $key => $value) {
if ($key == 'plugins') {
// Smartyプラグインディレクトリは配列で指定する
$tmp = array();
foreach (to_array($value) as $elt) {
$tmp[] = $this->base . '/' . $elt;
}
$directory[$key] = $tmp;
} else {
$directory[$key] = $this->base . '/' . $value;
}
}
$this->directory = $directory;
static::$instance = $this;
}
开发者ID:dqneo,项目名称:ethnam,代码行数:30,代码来源:Container.php
示例2: getJsParams
public function getJsParams()
{
$params = to_array($this->data->getJsParams());
//Всегда в параметрах js будет идентификатор текущей акции, для выполнения действия ajax
$params[STOCK_IDENT_PARAM] = $this->stock->getStockIdent();
return $params;
}
开发者ID:ilivanoff,项目名称:www,代码行数:7,代码来源:stock.php
示例3: assertPrepeared
private static function assertPrepeared($tableExists = null)
{
PsConnectionPool::assertConnectiedTo(PsConnectionParams::sdkTest());
foreach (to_array($tableExists) as $table) {
check_condition(PsTable::exists($table), "Таблица {$table} не существует");
}
}
开发者ID:ilivanoff,项目名称:www,代码行数:7,代码来源:PsDatabaseTestsHelper.php
示例4: get_user
function get_user($where = "")
{
$koneksi = connection();
$data = mysql_query("select * from userapp {$where};") or die("query error");
destroy_connection($koneksi);
return to_array($data);
}
开发者ID:handydannu,项目名称:WEB_PROJECT,代码行数:7,代码来源:function.php
示例5: executeQuery
/** @return ADORecordSet */
private static function executeQuery($query, $params = false, &$queryFinal = null, array &$paramsFinal = null)
{
$queryFinal = $query instanceof Query ? $query->build($params) : $query;
$queryFinal = normalize_string($queryFinal);
$paramsFinal = to_array($params);
$LOGGER = PsLogger::inst(__CLASS__);
$PROFILER = PsProfiler::inst(__CLASS__);
$PROFILER->start(strtolower($queryFinal));
try {
if ($LOGGER->isEnabled()) {
$LOGGER->info("[{$queryFinal}]" . ($paramsFinal ? ', PARAMS: ' . array_to_string($paramsFinal) : ''));
}
$rs = PsConnectionPool::conn()->execute($queryFinal, $paramsFinal);
if (is_object($rs)) {
$PROFILER->stop();
return $rs;
}
$error = PsConnectionPool::conn()->ErrorMsg();
$LOGGER->info('ERROR: {}', $error);
throw new DBException($error, DBException::ERROR_NOT_CLASSIFIED, $queryFinal, $paramsFinal);
} catch (Exception $ex) {
$PROFILER->stop(false);
if ($ex instanceof DBException) {
ExceptionHandler::dumpError($ex);
}
throw $ex;
}
}
开发者ID:ilivanoff,项目名称:www,代码行数:29,代码来源:PSDB.php
示例6: smarty_block_box
function smarty_block_box($params, $content, Smarty_Internal_Template &$smarty)
{
if ($content) {
$params['class'] = to_array(array_get_value('class', $params));
$params['class'][] = 'psbox';
return PsHtml::div($params, PsHtml::div(array('class' => 'psboxctt'), $content));
}
}
开发者ID:ilivanoff,项目名称:www,代码行数:8,代码来源:block.box.php
示例7: getAvatarImg
/**
* Метод возвращает <img /> элемент, готовый для вставки на страницу
*/
public static function getAvatarImg(PsUser $user = null, $dim = false, array $params = array())
{
$params['src'] = self::getAvatarDi($user, $dim);
$params['alt'] = $user ? $user->getName() : 'Аноним';
$params['data'] = $user ? array('uid' => $user->getId()) : null;
$params['class'] = to_array(array_get_value('class', $params));
$params['class'][] = array('avatar', $user ? 'user' : null);
return PsHtml::img($params);
}
开发者ID:ilivanoff,项目名称:ps-sdk-dev,代码行数:12,代码来源:PsUserHelper.php
示例8: spanImpl
private function spanImpl($itemName, array $attrs = array(), $class = null)
{
$attrs['class'] = to_array(array_get_value('class', $attrs));
$attrs['class'][] = $class;
$attrs['class'][] = 'sprite';
$attrs['class'][] = 'sprite-' . $this->name;
$attrs['class'][] = 'sprite-' . $this->name . '-' . $itemName;
return PsHtml::span($attrs);
}
开发者ID:ilivanoff,项目名称:www,代码行数:9,代码来源:CssSprite.php
示例9: getSmartyParams4Resources
public function getSmartyParams4Resources()
{
$result = array();
/* @var $item ShowcasesControllerItem */
foreach ($this->items as $item) {
$result = array_merge($result, to_array($item->getSmartyParams4Resources()));
}
return $result;
}
开发者ID:ilivanoff,项目名称:www,代码行数:9,代码来源:ShowcasesControllerPanel.php
示例10: traversable_sort
/**
* Sort values of a traversable and return new array with values in sorted order.
*
* @param callable|int $flags_or_comparator either one of SORT_* constants
* or a comparator function
* @param array|\Traversable $traversable a traversable to sort
* @return array array with sorted values
*/
function traversable_sort($flags_or_comparator, $traversable) : array
{
$array = to_array($traversable);
if (is_callable($flags_or_comparator)) {
usort($array, $flags_or_comparator);
} else {
sort($array, $flags_or_comparator);
}
return $array;
}
开发者ID:iddqdby,项目名称:f7,代码行数:18,代码来源:traversable_sort.php
示例11: psctrl
public static function psctrl(array $params)
{
$id = array_get_value_unset('id', $params);
$class = to_array(array_get_value_unset('class', $params));
$class[] = 'pscontrols';
if (!empty($params)) {
array_remove_keys($params, array_diff(array_keys($params), PsUtil::getClassConsts(__CLASS__, 'ACTION_')));
}
return empty($params) ? '' : PSSmarty::template('common/pscontrols.tpl', array('id' => $id, 'class' => PsHtml::classes2string($class), 'actions' => $params))->fetch();
}
开发者ID:ilivanoff,项目名称:www,代码行数:10,代码来源:SmartyFunctions.php
示例12: to_array
/**
* Array.
* @param iter $arg
* @param bool $deep
* @return array
*/
function to_array($arg, bool $deep = true) : array
{
$arg = (array) $arg;
if ($deep) {
foreach ($arg as $key => $value) {
$arg[$key] = is_iter($value) ? to_array($value, $deep) : $value;
}
}
return $arg;
}
开发者ID:froq,项目名称:froq-util,代码行数:16,代码来源:to.php
示例13: to_array
/**
* Convert an iterable to array.
* @param iter $input
* @param bool $deep
* @return array
*/
function to_array($input, bool $deep = true) : array
{
$input = (array) $input;
if ($deep) {
foreach ($input as $key => $value) {
$input[$key] = is_iter($value) ? to_array($value, $deep) : $value;
}
}
return $input;
}
开发者ID:froq,项目名称:froq-beta-archive,代码行数:16,代码来源:to.php
示例14: foreach
/**
* フォーム値の型チェックを行う
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
function &validate($name, $var, $params)
{
$true = true;
$type = $params['type'];
if ($type == VAR_TYPE_FILE || $this->isEmpty($var, $type)) {
return $true;
}
foreach (array_keys(to_array($var)) as $key) {
switch ($type) {
case VAR_TYPE_INT:
if (!preg_match('/^-?\\d+$/', $var)) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = "{form}には数字(整数)を入力して下さい";
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_INT);
}
break;
case VAR_TYPE_FLOAT:
if (!preg_match('/^-?\\d+$/', $var) && !preg_match('/^-?\\d+\\.\\d+$/', $var)) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = "{form}には数字(小数)を入力して下さい";
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_FLOAT);
}
break;
case VAR_TYPE_BOOLEAN:
if ($var != "1" && $var != "0") {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = "{form}には1または0のみ入力できます";
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_BOOLEAN);
}
break;
case VAR_TYPE_DATETIME:
$r = strtotime($var);
if ($r == -1 || $r === false) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = "{form}には日付を入力して下さい";
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_DATETIME);
}
break;
}
}
return $true;
}
开发者ID:hiroki-namekawa,项目名称:test-upr,代码行数:62,代码来源:Ethna_Plugin_Validator_Type.php
示例15: to_array
function to_array(&$obj)
{
if ($obj instanceof data) {
$obj = $obj->to_array();
}
if (is_array($obj)) {
foreach ($obj as &$el) {
to_array($el);
}
}
}
开发者ID:s-kalaus,项目名称:ekernel,代码行数:11,代码来源:crop.php
示例16: submit
public static function submit($buttons, $canReset)
{
$submits = '';
foreach (to_array($buttons) as $button) {
$submits .= PsHtml::input('submit', '', $button, array('class' => 'button'));
}
if ($canReset) {
$submits .= PsHtml::input('reset', '', 'Очистить', array('class' => 'button'));
}
return self::field(null, $submits);
}
开发者ID:ilivanoff,项目名称:www,代码行数:11,代码来源:PsHtmlForm.php
示例17: validate
/**
* フォーム値の型チェックを行う
*
* @access public
* @param string $name フォームの名前
* @param mixed $var フォームの値
* @param array $params プラグインのパラメータ
*/
public function validate($name, $var, $params)
{
$true = true;
$type = $params['type'];
if ($type == VAR_TYPE_FILE || $this->isEmpty($var, $type)) {
return $true;
}
foreach (array_keys(to_array($var)) as $key) {
switch ($type) {
case VAR_TYPE_INT:
if (!preg_match('/^-?\\d+$/', $var)) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input integer value to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_INT);
}
break;
case VAR_TYPE_FLOAT:
if (!preg_match('/^-?\\d+$/', $var) && !preg_match('/^-?\\d+\\.\\d+$/', $var)) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input float value to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_FLOAT);
}
break;
case VAR_TYPE_BOOLEAN:
if ($var != "1" && $var != "0") {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('You can input 0 or 1 to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_BOOLEAN);
}
break;
case VAR_TYPE_DATETIME:
$r = strtotime($var);
if ($r == -1 || $r === false) {
if (isset($params['error'])) {
$msg = $params['error'];
} else {
$msg = _et('Please input valid datetime to {form}.');
}
return Ethna::raiseNotice($msg, E_FORM_WRONGTYPE_DATETIME);
}
break;
}
}
return $true;
}
开发者ID:t-f-m,项目名称:ethna,代码行数:62,代码来源:Type.php
示例18: isCurPage
/**
* Проверяет, является ли переданная страница - текущей
*
* @param type $page
*/
public static function isCurPage($page)
{
$curPage = self::loadCurPage(false);
if (!$curPage instanceof WebPage) {
//Текущей вообще нет
return false;
}
foreach (to_array($page) as $page) {
if ($curPage->isIt($page)) {
return true;
}
}
return false;
}
开发者ID:ilivanoff,项目名称:www,代码行数:19,代码来源:WebPages.php
示例19: buildPage
/**
* Основная функция, выполняющая всю работу.
* Она следит за тем, что страница была корректно построена и в ответ вурнулся PageParams.
*
* @return PageParams
*/
public final function buildPage(PageContext $ctxt, PageBuilderContext $builderCtxt, RequestArrayAdapter $requestParams, ArrayAdapter $buildParams)
{
$this->profilerStart(__FUNCTION__);
try {
$smartyParams = to_array($this->doBuild($ctxt, $builderCtxt, $requestParams, $buildParams));
$pageParams = $this->foldedEntity->fetchTpl($smartyParams, FoldedResources::FETCH_RETURN_FULL_OB, true);
check_condition($pageParams instanceof PageParams, 'После фетчинга шаблона должен быть возвращен объект PageParams');
$this->profilerStop();
return $pageParams;
} catch (Exception $ex) {
$this->profilerStop(false);
throw $ex;
}
}
开发者ID:ilivanoff,项目名称:ps-sdk-dev,代码行数:20,代码来源:AbstractPageBuilder.php
示例20: getParentBlock
public function getParentBlock($blockNames, $__FUNCTION__, $mandatory)
{
$blockNames = to_array($blockNames);
foreach ($blockNames as $name) {
if ($this->hasContext($name)) {
return $name;
}
}
if ($mandatory) {
$text = "Function {$__FUNCTION__} must have one of this parents: " . implode(',', $blockNames);
$this->LOGGER->info($text);
check_condition(false, $text);
}
return null;
}
开发者ID:ilivanoff,项目名称:www,代码行数:15,代码来源:SmartyBlockContext.php
注:本文中的to_array函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论