当前位置: 首页>>代码示例>>PHP>>正文


PHP array_is_associative函数代码示例

本文整理汇总了PHP中array_is_associative函数的典型用法代码示例。如果您正苦于以下问题:PHP array_is_associative函数的具体用法?PHP array_is_associative怎么用?PHP array_is_associative使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了array_is_associative函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: strip

 public function strip($V2063c1608d6e0baf80249c42e2be58)
 {
     if (is_array($V2063c1608d6e0baf80249c42e2be58)) {
         if (array_is_associative($V2063c1608d6e0baf80249c42e2be58)) {
             foreach ($V2063c1608d6e0baf80249c42e2be58 as $V8ce4b16b22b58894aa86c421e8759d => $V9e3669d19b675bd57058fd4664205d) {
                 $Vafb0f4ba8bde6746418ba7f1fbfc9e[$V8ce4b16b22b58894aa86c421e8759d] = stripslashes($V9e3669d19b675bd57058fd4664205d);
             }
             $V2063c1608d6e0baf80249c42e2be58 = $Vafb0f4ba8bde6746418ba7f1fbfc9e;
         } else {
             for ($V363b122c528f54df4a0446b6bab055 = 0; $V363b122c528f54df4a0446b6bab055 < sizeof($V2063c1608d6e0baf80249c42e2be58); $V363b122c528f54df4a0446b6bab055++) {
                 $V2063c1608d6e0baf80249c42e2be58[$V363b122c528f54df4a0446b6bab055] = stripslashes($V2063c1608d6e0baf80249c42e2be58[$V363b122c528f54df4a0446b6bab055]);
             }
         }
     } else {
         $V2063c1608d6e0baf80249c42e2be58 = stripslashes($V2063c1608d6e0baf80249c42e2be58);
     }
     return $V2063c1608d6e0baf80249c42e2be58;
 }
开发者ID:hendisantika,项目名称:crudphpgrid,代码行数:18,代码来源:jqgrid_dist.php

示例2: Strip

function Strip($value)
{
    if (get_magic_quotes_gpc() != 0) {
        if (is_array($value)) {
            if (array_is_associative($value)) {
                foreach ($value as $k => $v) {
                    $tmp_val[$k] = stripslashes($v);
                }
                $value = $tmp_val;
            } else {
                for ($j = 0; $j < sizeof($value); $j++) {
                    $value[$j] = stripslashes($value[$j]);
                }
            }
        } else {
            $value = stripslashes($value);
        }
    }
    return $value;
}
开发者ID:rokfeller,项目名称:webui,代码行数:20,代码来源:search.php

示例3: strip

 private function strip($V2063c160)
 {
     if (get_magic_quotes_gpc() != 0) {
         if (is_array($V2063c160)) {
             if (array_is_associative($V2063c160)) {
                 foreach ($V2063c160 as $V8ce4b16b => $V9e3669d1) {
                     $Vafb0f4ba[$V8ce4b16b] = stripslashes($V9e3669d1);
                 }
                 $V2063c160 = $Vafb0f4ba;
             } else {
                 for ($V363b122c = 0; $V363b122c < sizeof($V2063c160); $V363b122c++) {
                     $V2063c160[$V363b122c] = stripslashes($V2063c160[$V363b122c]);
                 }
             }
         } else {
             $V2063c160 = stripslashes($V2063c160);
         }
     }
     return $V2063c160;
 }
开发者ID:kristijana,项目名称:Administriranje,代码行数:20,代码来源:jqgrid_dist.php

示例4: ucfirst

         $admin_data_array[$key] = (int) $admin_data_array[$key];
         if (array_key_exists($optionLoopCounter, $option_value_array) && $option_value_array[$optionLoopCounter] == 1) {
             $selected = ' selected="selected"';
         } else {
             $selected = '';
         }
         $admin_page .= '                      <option value="' . $optionLoopCounter . '"' . $selected . '>' . ucfirst($option_value);
         $admin_page .= '</option>' . $LINEBREAK;
         $optionLoopCounter++;
     }
     $admin_page .= '</select>' . $readonly_message . '</span><br />' . $LINEBREAK;
 } elseif ($value['type'] == 'select') {
     //SELECT
     $js_default_values['select'][] = array('key' => $key, 'warning' => $warningText, 'count' => count($value['options']));
     $optionLoopCounter = 0;
     $associativeArray = array_is_associative($value['options']);
     $admin_page .= '<span id="' . $key . '_wrapper" class="' . $highlightFieldCSS . '"><select name="' . $key . '" id="' . $key . '" class="listbox" size="1" ' . $readonly_radio . ' tabindex="' . $tabindexCounter . '" title="' . str_replace("'", "\\'", htmlspecialchars($warningText)) . '">';
     foreach ($value['options'] as $option_key => $option_value) {
         // loop through the options array
         if ($associativeArray == TRUE) {
             if ($admin_data_array[$key] == $option_key) {
                 $selected = ' selected="selected"';
             } else {
                 $selected = '';
             }
             $admin_page .= '<option value="' . $option_key . '"' . $selected . '>' . $option_value;
         } else {
             if ($admin_data_array[$key] == $option_value) {
                 $selected = ' selected="selected"';
             } else {
                 $selected = '';
开发者ID:stephenjschaefer,项目名称:APlusPhotography,代码行数:31,代码来源:admin.php

示例5: setFields

function setFields($object, array $fieldArray = null)
{
    // helper method that allows creating objects and setting their properties based on an associative array passed as argument. Mimics functionality from PHP toolkit
    $classname = get_class($object);
    // a static map that maps class parameters to their types. needed for knowing which objects to create
    $typesmap = $classname::$paramtypesmap;
    if (!isset($typesmap)) {
        // if the class does not have paramtypesmap, consider it empty
        $typesmap = array();
    }
    if ($fieldArray == null) {
        // nothign to do
        return;
    }
    foreach ($fieldArray as $fldName => $fldValue) {
        if ((is_null($fldValue) || $fldValue == "") && $fldValue !== false || arrayValuesAreEmpty($fldValue)) {
            //empty param
            continue;
        }
        if (!isset($typesmap[$fldName])) {
            // the value is not a valid class atrribute
            trigger_error("SetFields error: parameter \"" . $fldName . "\" is not a valid parameter for an object of class \"" . $classname . "\", it will be omitted", E_USER_WARNING);
            continue;
        }
        if ($fldValue === 'false') {
            // taken from the PHP toolkit, but is it really necessary?
            $object->{$fldName} = false;
        } elseif (is_object($fldValue)) {
            $object->{$fldName} = $fldValue;
        } elseif (is_array($fldValue) && array_is_associative($fldValue)) {
            // example: 'itemList'  => array('item' => array($item1, $item2), 'replaceAll'  => false)
            if (substr($typesmap[$fldName], -2) == "[]") {
                trigger_error("Trying to assign an object into an array parameter \"" . $fldName . "\" of class \"" . $classname . "\", it will be omitted", E_USER_WARNING);
                continue;
            }
            $class = 'NetSuite\\Classes\\' . $typesmap[$fldName];
            $obj = new $class();
            setFields($obj, $fldValue);
            $object->{$fldName} = $obj;
        } elseif (is_array($fldValue) && !array_is_associative($fldValue)) {
            // array type
            if (substr($typesmap[$fldName], -2) != "[]") {
                // the type is not an array, skipping this value
                trigger_error("Trying to assign an array value into parameter \"" . $fldName . "\" of class \"" . $classname . "\", it will be omitted", E_USER_WARNING);
                continue;
            }
            // get the base type  - the string is of type <type>[]
            $basetype = substr($typesmap[$fldName], 0, -2);
            // example: 'item' => array($item1, $item2)
            foreach ($fldValue as $item) {
                if (is_object($item)) {
                    // example: $item1 = new nsComplexObject('SalesOrderItem');
                    $val[] = $item;
                } elseif ($typesmap[$fldName] == "string") {
                    // handle enums
                    $val[] = $item;
                } else {
                    // example: $item2 = array( 'item'      => new nsComplexObject('RecordRef', array('internalId' => '17')),
                    //                          'quantity'  => '3')
                    $class = 'NetSuite\\Classes\\' . $basetype;
                    $obj = new $class();
                    setFields($obj, $item);
                    $val[] = $obj;
                }
            }
            $object->{$fldName} = $val;
        } else {
            $object->{$fldName} = $fldValue;
        }
    }
}
开发者ID:fungku,项目名称:netsuite-php,代码行数:71,代码来源:functions.php

示例6: test_array_is_associative

 /**
  * @dataProvider array_is_associative_provider
  */
 public function test_array_is_associative($expected, $array)
 {
     $this->assertEquals($expected, array_is_associative($array));
 }
开发者ID:weew,项目名称:helpers-array,代码行数:7,代码来源:ArrayTest.php

示例7: array_is_indexed

 /**
  * Check if an array has a numeric index.
  *
  * @param array $array
  *
  * @return bool
  */
 function array_is_indexed(array $array)
 {
     if ($array == []) {
         return true;
     }
     return !array_is_associative($array);
 }
开发者ID:weew,项目名称:helpers-array,代码行数:14,代码来源:array.php

示例8: printFormattedArray

 function printFormattedArray($arr, $autoTitle = true, $format = null)
 {
     if ($format == null) {
         if (isset($_REQUEST["format"])) {
             $format = $_REQUEST["format"];
         } else {
             $format = "select";
         }
     }
     $format = strtolower($format);
     //HTML Format
     if ($format == "select") {
         if (!array_is_associative($arr)) {
             foreach ($arr as $a => $b) {
                 if ($autoTitle) {
                     echo "<option title='{$b}' value='{$b}'>" . toTitle(_ling($b)) . "</option>\n";
                 } else {
                     echo "<option title='{$b}' value='{$b}'>" . _ling($b) . "</option>\n";
                 }
             }
         } else {
             foreach ($arr as $a => $b) {
                 $xs = "";
                 if (is_array($b)) {
                     $xx = array();
                     foreach ($b as $x => $y) {
                         $xx[] = "{$x}='{$y}'";
                     }
                     $xs = implode(" ", $xx);
                     if (isset($b['value'])) {
                         $b = $b['value'];
                     } else {
                         $b = $a;
                     }
                 }
                 if ($autoTitle) {
                     echo "<option title='{$a}' value='{$b}' {$xs}>" . toTitle(_ling($a)) . "</option>\n";
                 } else {
                     echo "<option title='{$a}' value='{$b}' {$xs}>" . _ling($a) . "</option>\n";
                 }
             }
         }
     } elseif ($format == "table") {
         foreach ($arr as $a => $b) {
             $s = "<tr rel='{$a}'>";
             if (is_array($b)) {
                 foreach ($b as $x => $y) {
                     if (is_numeric($y)) {
                         $s .= "<td name='{$x}' rel='{$y}' align=center>" . toTitle(_ling($y)) . "</td>";
                     } elseif (is_array($y)) {
                         $xs = "";
                         foreach ($y as $u => $v) {
                             $xx[] = "{$u}='{$v}'";
                         }
                         $xs = implode(" ", $xx);
                         if (isset($y['value'])) {
                             $y = $y['value'];
                         } else {
                             $y = $x;
                         }
                         $s .= "<td name='{$x}' rel='{$y}' {$xs}>" . toTitle(_ling($y)) . "</td>";
                     } elseif (is_bool($y) || $y == "true" || $y == "false") {
                         if ($y == "true" || $y == 1) {
                             $s .= "<td name='{$x}' rel='{$y}' align=center><input name={$x} type=checkbox checked /></td>";
                         } else {
                             $s .= "<td name='{$x}' rel='{$y}' align=center><input name={$x} type=checkbox /></td>";
                         }
                     } else {
                         if (strpos("#" . $y, "<") == 1) {
                             $s .= "<td name='{$x}' rel='{$x}'>{$y}</td>";
                         } elseif (strpos($y, "@") === 0) {
                             $y = substr($y, 1);
                             $s .= "<td name='{$x}' rel='{$x}'>{$y}</td>";
                         } else {
                             $s .= "<td name='{$x}' rel='{$y}'>" . toTitle(_ling($y)) . "</td>";
                         }
                     }
                 }
             } else {
                 $s .= "<td name='{$a}' rel='{$b}'>" . toTitle(_ling($b)) . "</td>";
             }
             $s .= "</tr>\n";
             echo $s;
         }
     } elseif ($format == "list") {
         if (!array_is_associative($arr)) {
             foreach ($arr as $a => $b) {
                 if (is_array($b)) {
                     echo "<ul>\n";
                     printFormattedArray($b, $autoTitle, $format);
                     echo "</ul>\n";
                 } else {
                     if ($autoTitle) {
                         echo "<li title='{$b}' value='{$b}'>" . toTitle(_ling($b)) . "</li>\n";
                     } else {
                         echo "<li title='{$b}' value='{$b}'>" . _ling($b) . "</li>\n";
                     }
                 }
             }
         } else {
//.........这里部分代码省略.........
开发者ID:kshyana,项目名称:Logiks-Core,代码行数:101,代码来源:formatprint.php

示例9: strip

	/**
	 * Helping function to parse array
	 */
	public function strip($value)
	{
		// gpc line removed for wp plugin search fix
		// if(get_magic_quotes_gpc() != 0)
		{
			if(is_array($value))  
				if ( array_is_associative($value) )
				{
					foreach( $value as $k=>$v)
						$tmp_val[$k] = stripslashes($v);
					$value = $tmp_val; 
				}				
				else  
					for($j = 0; $j < sizeof($value); $j++)
						$value[$j] = stripslashes($value[$j]);
			else
				$value = stripslashes($value);
		}
		return $value;
	}	
开发者ID:ranvijayj,项目名称:htmlasa,代码行数:23,代码来源:jqgrid.php

示例10: strip

 private function strip($R7D0596C36891967F3BB9D994B4A97C19)
 {
     if (get_magic_quotes_gpc() != 0) {
         if (is_array($R7D0596C36891967F3BB9D994B4A97C19)) {
             if (array_is_associative($R7D0596C36891967F3BB9D994B4A97C19)) {
                 foreach ($R7D0596C36891967F3BB9D994B4A97C19 as $RA09FE38AF36F6839F4A75051DC7CEA25 => $RA3D52E52A48936CDE0F5356BB08652F2) {
                     $R0C07CA587B7BAAD6E37E765539CFFFEE[$RA09FE38AF36F6839F4A75051DC7CEA25] = stripslashes($RA3D52E52A48936CDE0F5356BB08652F2);
                 }
                 $R7D0596C36891967F3BB9D994B4A97C19 = $R0C07CA587B7BAAD6E37E765539CFFFEE;
             } else {
                 for ($RA7B9A383688A89B5498FC84118153069 = 0; $RA7B9A383688A89B5498FC84118153069 < sizeof($R7D0596C36891967F3BB9D994B4A97C19); $RA7B9A383688A89B5498FC84118153069++) {
                     $R7D0596C36891967F3BB9D994B4A97C19[$RA7B9A383688A89B5498FC84118153069] = stripslashes($R7D0596C36891967F3BB9D994B4A97C19[$RA7B9A383688A89B5498FC84118153069]);
                 }
             }
         } else {
             $R7D0596C36891967F3BB9D994B4A97C19 = stripslashes($R7D0596C36891967F3BB9D994B4A97C19);
         }
     }
     return $R7D0596C36891967F3BB9D994B4A97C19;
 }
开发者ID:cdnsolution,项目名称:LeERP,代码行数:20,代码来源:jqgrid_dist.php


注:本文中的array_is_associative函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。