本文整理匯總了PHP中ArrayHelper::is_associative方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayHelper::is_associative方法的具體用法?PHP ArrayHelper::is_associative怎麽用?PHP ArrayHelper::is_associative使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper::is_associative方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __parse_block_into_array
function __parse_block_into_array ()
{
$hash = array();
while ($this->__index < count($this->__elements))
{
$element = &$this->__elements[$this->__index];
$this->__index++;
$key = Inflector::underscore($element['tag']);
$attributes = array();
if (isset($element['attributes']))
{
foreach ($element['attributes'] as $k => $v)
$attributes[strtolower($k)] = $v;
}
$value = null;
switch($element['type'])
{
case 'open':
$value = $this->__parse_block_into_array();
break;
case 'complete':
$value = isset($element['value']) ? $element['value'] : '';
if (isset($attributes['encoding']) && $attributes['encoding'] == 'base64')
$value = base64_decode($value);
break;
case 'close':
return $hash;
default:
// ignore other element types
}
if (!is_null($value))
{
if (isset($hash[$key]))
{
if (!is_array($hash[$key]) || ArrayHelper::is_associative($hash[$key]))
$hash[$key] = array($hash[$key], $value);
else
array_push($hash[$key], $value);
}
else
$hash[$key] = $value;
}
}
return $hash;
}
示例2: __find_all
function __find_all ($class)
{
$query_string = "";
if (count($class->attributes) > 0)
$query_string = "?" . join('&', array_map(create_function('$a,$b', 'return "$a=$b";'), array_keys($class->attributes), array_values($class->attributes)));
$response = $this->__request($class, 'GET', $query_string);
$parser = new XMLParser();
$array = $parser->parse_into_array($response->body);
$class_name = "SS" . $class->class_name();
$singular = Inflector::underscore($class->class_name());
$plural = Inflector::pluralize($singular);
$records = $array[$plural][$singular];
if (ArrayHelper::is_associative($records))
$records = array($records);
$objects = array();
foreach ($records as $attrs)
$objects[] = new $class_name($attrs);
return $objects;
}