本文整理汇总了PHP中kArray::array_is_associative方法的典型用法代码示例。如果您正苦于以下问题:PHP kArray::array_is_associative方法的具体用法?PHP kArray::array_is_associative怎么用?PHP kArray::array_is_associative使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kArray
的用法示例。
在下文中一共展示了kArray::array_is_associative方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array2xmlImpl
protected function array2xmlImpl($array, $num_prefix = "num_", $depth = 0)
{
$depth++;
// echo ( "[$depth]array2xmlImpl:" . print_r ( $array , true ) . "<br>");
// echo ( "[$depth]--array2xmlImpl: $num_prefix <br>");
$result = "";
if ($array instanceof myBaseObject) {
/*
* $obj = objectWrapperBase::toArrayImpl ( $array );
$result.= self::array2xmlImpl( $array, $num_prefix , $depth);
*/
$result = null;
$fields = $array->getFieldNames();
foreach ($fields as $key) {
if (empty($key)) {
continue;
}
$val = $array->get($key);
// TODO - think if want to compare to === null -
// this will return 0 and empty strings (doesn't happen now)
//if ( empty ( $val ) && ( $val !== 0 ) ) continue;
if (!self::shouldDisplayValue($val)) {
continue;
}
try {
$key = self::tagNameFromField($key, $num_prefix);
// fix key if needed
$result .= "<" . $key . ">" . self::array2xmlImpl($val, $num_prefix, $depth) . "</" . $key . ">";
} catch (Exception $ex) {
$result .= "<" . $key . ">ERROR</" . $key . ">";
}
}
} else {
if ($array instanceof objectWrapperBase) {
/*
$obj = $array->toArray();
$result.= self::array2xmlImpl( $array, $num_prefix , $depth);
*/
$result = "";
$fields = $array->getFieldNames();
$i = 0;
foreach ($fields as $key) {
if (empty($key)) {
continue;
}
$val = $array->get($key);
if (!self::shouldDisplayValue($val)) {
continue;
}
try {
$key = self::tagNameFromField($key, $num_prefix);
// fix key if needed
$result .= "<" . $key . ">" . self::array2xmlImpl($val, $num_prefix, $depth) . "</" . $key . ">";
} catch (Exception $ex) {
$result .= "<" . $key . ">ERROR</" . $key . ">";
}
}
} elseif (is_array($array)) {
$result = "";
if (kArray::array_is_associative($array)) {
foreach ($array as $key => $val) {
try {
$key = self::tagNameFromField($key, $num_prefix);
// fix key if needed
$result .= "<" . $key . ">" . self::array2xmlImpl($val, $num_prefix, $depth) . "</" . $key . ">";
} catch (Exception $ex) {
$result .= "<" . $key . ">ERROR</" . $key . ">";
}
}
} else {
$array_size = count($array);
for ($i = 0; $i < $array_size; ++$i) {
if (key_exists($i, $array)) {
$val = $array[$i];
} else {
}
try {
$key = self::tagNameFromField($i, $num_prefix);
// fix key if needed
$result .= "<" . $key . ">" . self::array2xmlImpl($val, $num_prefix, $depth) . "</" . $key . ">";
} catch (Exception $ex) {
$result .= "<" . $key . ">ERROR</" . $key . ">";
}
}
}
} elseif (is_object($array)) {
return "ERROR fromating object of type [" . get_class($array) . "]";
//echo ( "[$depth]array2xmlImpl:is_object " . get_class ( $array ) . "<br>" );
} else {
//cho ( "[$depth]array2xmlImpl: " . get_class ( $array ) . "<br>");
//return htmlentities ( $array );
if ($this->escape_text) {
// TODO - decide whether to encode or cdata or nothing - according to the name of the field
$escaped = kString::xmlEncode($array);
return $escaped;
/*
if ( $escaped != $array )
{
return "<![CDATA[$array]]>";
}
//.........这里部分代码省略.........