• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_assoc函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: query

 /**
  * Creates and executes a prepared statement.
  *
  * The purpose of prepared statements is to execute a single query multiple times quickly using different variables.
  * However, we are using them here for security purposes, aware of the fact that preparing and executing single statements
  * one at a time goes against the intention of prepared statements. See "Escaping and SQL Injection" at
  * http://php.net/manual/en/mysqli.quickstart.prepared-statements.php
  *
  * For insert and update queries, passing an associative array of column names and values along with the first few
  * words of the query, up to and including the table name, is sufficient.
  *
  * Example:
  *	$my_table_values = array(
  *		'Person' => 'Bob Jones',
  *		'Company => 'BJ Manufacturing'
  *	);
  *	$query_fragment	= "INSERT INTO `my_table`";
  *	database->query( $query_fragment, $my_table_values );
  *
  * @param string [$query] Either a valid SQL query or the start of one accompanied by an associative array
  * @param array [$params] Optional. Either a list of values that will be bound to the prepared statement or an associative
  * array whose keys match the table's column names.
  * @return mixed [$result or $success] The result of a SQL SELECT, else boolean.
  */
 public function query($query, $params = null)
 {
     if (mysqli_connect_error()) {
         throw new Exception('Failed to connect(' . mysqli_connect_errno() . '): ' . mysqli_connect_error());
     }
     //var_dump( 'before: ', $query, $params );
     if (empty($params)) {
         $statement = $this->prepare($query);
         return $this->execute($statement);
     } else {
         if (!is_array($params)) {
             $params = array($params);
             // convert to array because $this->bind_params requires it
         } else {
             if (is_assoc($params)) {
                 // @todo finish reduce_params( $table_name, $params );
                 // stick $params keys into $query
                 $query = $this->build_query_from_associative_array($query, array_keys($params));
                 // Because we've just filled in the keys (column names), we only need to pass the values
                 $params = array_values($params);
             }
         }
         //var_dump( 'after: ', $query, $params );
         $statement = $this->prepare($query);
         return $this->execute($statement, $params);
     }
 }
开发者ID:Garrett-Sens,项目名称:portfolio,代码行数:51,代码来源:mysql.php


示例2: init

	public function init()
	{	
		parent::init();

		$this->current_index = 0;
		
		// make sure $field was specified
		if (!$this->field)
			throw new Exception("field must be specified in resultfilter control");
		$this->filter_definition = $this->controller->appmeta->filter->{$this->field};
		
		if (!$this->datasource) /* Default to the datasource definition in the config file */
			$this->datasource = $this->filter_definition->datasource;
		$filter_type = $this->filter_definition->type;

		// Set container and item templates from config file if not passed into tag
		if (!$this->item_template)
			$this->item_template = $this->controller->appmeta->renderer_map->{$filter_type}->item;
			
		if (!$this->container_template)
			$this->container_template = $this->controller->appmeta->renderer_map->{$filter_type}->container;
				
		// dig specific facet counts out of facets
		if (is_assoc($this->datasource))
		{
			$facet = $this->datasource[$this->filter_definition->facet->field];
			$this->datasource = array();
			foreach($facet as $value => $count)
				$this->datasource[] = array('value' => $value, 'count' => $count); 
		}
	}
开发者ID:nikels,项目名称:HeavyMetal,代码行数:31,代码来源:resultfilter.php


示例3: testIsAssoc

 public function testIsAssoc()
 {
     $arr = ['a' => 0, 'b' => 1];
     $this->assertTrue(is_assoc($arr));
     $arr = ['a', 'b', 'c'];
     $this->assertFalse(is_assoc($arr));
 }
开发者ID:a11enwong,项目名称:pochika,代码行数:7,代码来源:HelpersTest.php


示例4: recursive

 function recursive($array, $level = 1)
 {
     $cur = 1;
     foreach ($array as $key => $value) {
         //If $value is an array.
         if (is_array($value)) {
             if (!is_numeric($key)) {
                 echo '"' . $key . '": ';
             }
             if (is_assoc($value)) {
                 echo '{ ';
             } else {
                 echo '[ ';
             }
             //We need to loop through it.
             recursive($value, $level + 1);
             if (is_assoc($value)) {
                 echo ' }';
             } else {
                 echo ' ]';
             }
         } else {
             //It is not an array, so print it out.
             echo '"' . $key . '": "' . $value, '"';
         }
         if ($cur != count($array)) {
             echo ', ';
         }
         $cur++;
     }
 }
开发者ID:baltedewit,项目名称:slogo-playout-server,代码行数:31,代码来源:api.php


示例5: __construct

 /**
  * __construct method
  * @param array $array
  * @array array $args
  * */
 public function __construct($array, $args)
 {
     $this->array = $array;
     $this->args = $args;
     is_assoc($this->array) ? $this->assocArray() : $this->sequentArray();
     $this->setRouting(implode('/', $this->array) . '/' . $this->args);
 }
开发者ID:varyan,项目名称:namecpaseSystem,代码行数:12,代码来源:RoutArray.php


示例6: array_str

function array_str($arr, $var_export_all = false)
{
    $is_assoc = is_assoc($arr);
    $result = '[';
    foreach ($arr as $key => $value) {
        if ($is_assoc) {
            $result .= $key . '=';
        }
        if (is_array($value)) {
            $result .= array_str($value);
        } else {
            if ($var_export_all) {
                $result .= var_export($value, true);
            } else {
                if (is_bool($value)) {
                    $result .= bool_str($value);
                } else {
                    if (is_string($value)) {
                        $result .= '"' . $value . '"';
                    } else {
                        if (is_string_convertable($value)) {
                            $result .= $value;
                        } else {
                            $result .= var_export($value, true);
                        }
                    }
                }
            }
        }
        $result .= ', ';
    }
    return remove_last($result, ', ') . ']';
}
开发者ID:matthew0x40,项目名称:apply,代码行数:33,代码来源:functions.php


示例7: __construct

 /**
  * Constructor
  *
  * @param array  $array     multidimensional associative array
  * @param string $separator [optional] default '.'
  *
  * @throws NonAssocException
  */
 public function __construct(array $array, $separator = '.')
 {
     if (!is_assoc($array)) {
         throw new NonAssocException();
     }
     $this->storage = $array;
     $this->separator = $separator;
 }
开发者ID:acim,项目名称:stdlib,代码行数:16,代码来源:DotArray.php


示例8: _refresh

 /**
  * @return $this
  */
 public function _refresh()
 {
     if (!is_assoc($this->_result)) {
         return $this;
     }
     DB::_getInstance()->query("UPDATE `Token` SET `Created` = NULL WHERE `ID` = {$this->_result['ID']};");
     return $this;
 }
开发者ID:enderteszla,项目名称:phpframework-etc,代码行数:11,代码来源:Token.php


示例9: copyKeys

 /**
  * Copy nodes
  *
  * @param array $keys associative array
  *
  * @throws NonAssocException
  *
  * @return $this
  */
 public function copyKeys(array $keys)
 {
     if (!is_assoc($keys)) {
         throw new NonAssocException();
     }
     foreach ($keys as $existingKey => $newKey) {
         $this->array->offsetSet($newKey, $this->array->offsetGet($existingKey));
     }
     return $this;
 }
开发者ID:acim,项目名称:stdlib,代码行数:19,代码来源:ArrayModifier.php


示例10: parseMatch

function parseMatch($match, $MAJOR_ITEMS)
{
    //Strip fields from participants
    // $support_1;
    // $support_2;
    $counter = 0;
    foreach ($match['participants'] as $participant) {
        // if ($participant['timeline']['role'] == 'DUO_SUPPORT' && $participant['teamId'] == 100)
        // 	$support_1 = $participant['participantId'];
        // if ($participant['timeline']['role'] == 'DUO_SUPPORT' && $participant['teamId'] == 200)
        // 	$support_2 = $participant['participantId'];
        unset($match['participants'][$counter]['masteries']);
        unset($match['participants'][$counter]['runes']);
        foreach ($participant['stats'] as $key => $value) {
            if ($key != 'deaths' && $key != 'kills' && $key != 'assists' && $key != 'winner') {
                unset($match['participants'][$counter]['stats'][$key]);
            }
        }
        $counter++;
    }
    unset($match['participantIdentities']);
    unset($match['teams']);
    //Strip events
    $frame_counter = 0;
    if (is_assoc($match['timeline']['frames'])) {
        return $match;
        //don't change doc at all
    }
    foreach ($match['timeline']['frames'] as $frame) {
        unset($match['timeline']['frames'][$frame_counter]['participantFrames']);
        if (isset($frame['events'])) {
            $counter = 0;
            foreach ($frame['events'] as $event) {
                if ($event['eventType'] != 'ITEM_PURCHASED') {
                    unset($match['timeline']['frames'][$frame_counter]['events'][$counter]);
                } else {
                    // if ($event['participantId'] != $support_1 && $event['participantId'] != $support_2 && !in_array($event['itemId'], $MAJOR_ITEMS['items']))
                    if (!in_array($event['itemId'], $MAJOR_ITEMS['items'])) {
                        unset($match['timeline']['frames'][$frame_counter]['events'][$counter]);
                    }
                    //remove event if not a major purchase by non-support
                }
                $counter++;
            }
            if (count($match['timeline']['frames'][$frame_counter]['events']) == 0) {
                unset($match['timeline']['frames'][$frame_counter]);
            }
        }
        $frame_counter++;
    }
    return $match;
}
开发者ID:AndrewAday,项目名称:Riot-API-Challenge-2.0,代码行数:52,代码来源:parse_match.php


示例11: replace

 public static function replace($subject, $variables)
 {
     if (is_array($variables) && is_assoc($variables)) {
         foreach ($variables as $key => $value) {
             $key = str_replace("[", "\\[", $key);
             $key = str_replace("]", "\\]", $key);
             $subject = preg_replace("/\\{\\{{$key}\\}\\}/", $value, $subject);
         }
         /* Remove any variables remaining */
         $subject = preg_replace("/\\{\\{[^}]*\\}\\}/", "", $subject);
     }
     return $subject;
 }
开发者ID:mbruton,项目名称:email_templates,代码行数:13,代码来源:model_email_template.php


示例12: setProperties

 public function setProperties($properties)
 {
     if (!is_array($properties)) {
         $properties = func_get_args();
     } elseif (is_assoc($properties)) {
         foreach ($properties as $key => $value) {
             $this->settable_properties[$key] = $value;
         }
         return;
     }
     foreach ($properties as $property) {
         $this->settable_properties[$property] = "";
     }
 }
开发者ID:BackupTheBerlios,项目名称:anemone,代码行数:14,代码来源:SettingsStore.php


示例13: is_red

function is_red($ob)
{
    if (!is_array($ob)) {
        return false;
    }
    if (!is_assoc($ob)) {
        return false;
    }
    foreach ($ob as $val) {
        if ($val === 'red') {
            return true;
        }
    }
    return false;
}
开发者ID:JimMackin,项目名称:AdventOfCode,代码行数:15,代码来源:day12-2.php


示例14: recursive_add

function recursive_add($obj)
{
    $total = 0;
    foreach ($obj as $k => $v) {
        if (is_scalar($v)) {
            $total += $v;
            if ($v === "red" && is_assoc($obj)) {
                // part 2
                return 0;
            }
        } else {
            $total += recursive_add($obj[$k]);
        }
    }
    return $total;
}
开发者ID:altef,项目名称:AdventOfCode,代码行数:16,代码来源:Day12.php


示例15: parse

 public function parse()
 {
     if (!$this->map) {
         throw new CSVParserException('$map must be defined.');
     }
     if (!is_assoc($this->map)) {
         throw new CSVParserException('$map must be associative.');
     }
     if (!$this->delimiter) {
         throw new CSVParserException('$delimiter must be defined.');
     }
     if (!$this->path) {
         throw new CSVParserException('$path must be defined.');
     }
     $csv = $this->remote ? $this->_getRemoteCSV() : $this->_getLocalCSV();
     return $csv;
 }
开发者ID:hshoghi,项目名称:cms,代码行数:17,代码来源:class.CSVParser.php


示例16: print_select

function print_select($name, $options = array(), $selected = NULL)
{
    echo "<select name=\"{$name}\">";
    if (!is_assoc($options)) {
        $new_options = array();
        foreach ($options as $option) {
            $new_options[$option] = $option;
        }
    }
    foreach ($options as $option => $text) {
        $setxt = "";
        if (!is_null($selected) && $selected == $option) {
            $setxt = " selected";
        }
        echo "<option value=\"{$option}\"{$setxt}>{$text}</option>";
    }
    echo "</select>";
}
开发者ID:jamuraa,项目名称:gatherling,代码行数:18,代码来源:lib_form_helper.php


示例17: icon_switch

function icon_switch($case, $icons)
{
    $icon = '';
    if (is_numeric($case) && !is_assoc($icons)) {
        $case %= count($icons);
    }
    if (isset($icons[$case])) {
        if (is_array($icons[$case])) {
            $icon = $icons[$case]['icon'];
            $url = isset($icons[$case]['url']) ? $icons[$case]['url'] : FALSE;
            $attr = isset($icons[$case]['attr']) ? $icons[$case]['attr'] : array();
            $icon = icon($icon, $url, $attr);
        } else {
            $icon = icon($icons[$case]);
        }
    }
    return $icon;
}
开发者ID:jayalfredprufrock,项目名称:winx,代码行数:18,代码来源:bootstrap_helper.php


示例18: convert

function convert($currency_value, $your_currencies)
{
    global $exchangeRates, $currencies;
    if (isset($your_currencies)) {
        $list_currencies = $your_currencies;
    } elseif (isset($currencies)) {
        $list_currencies = $currencies;
    } else {
        $list_currencies = (array) $exchangeRates->rates;
    }
    foreach ($list_currencies as $key => $value) {
        if (is_assoc($list_currencies)) {
            $return_list[$key] = convert_to($currency_value, $key);
        } else {
            $return_list[$value] = convert_to($currency_value, $value);
        }
    }
    return $return_list;
}
开发者ID:stealthsnake,项目名称:openexchangerates_php,代码行数:19,代码来源:openexchangerates_config.php


示例19: package_maintainers

 public function package_maintainers()
 {
     $this->package = Package::find_by_name($_GET['name']);
     $data = unserialize(Version::find('first', array('conditions' => array('package_id' => $this->package->id)))->meta);
     $this->maintainers = array();
     foreach (array('lead', 'developer', 'contributor', 'helper') as $role) {
         if (isset($data[$role]) && !empty($data[$role])) {
             if (!is_assoc($data[$role])) {
                 foreach ($data[$role] as $node) {
                     $node['role'] = $role;
                     $this->maintainers[] = $node;
                 }
             } else {
                 $data[$role]['role'] = $role;
                 $this->maintainers[] = $data[$role];
             }
         }
     }
 }
开发者ID:scottdavis,项目名称:pearfarm_channel_server,代码行数:19,代码来源:rest_controller.php


示例20: __construct

 public function __construct($o = array())
 {
     if (!$o) {
         throw new \Exception('Constructor arguments required.');
     }
     if (!\is_assoc($o)) {
         throw new \Exception('Contsructor argument needs to be associative.');
     }
     $o = (object) $o;
     $this->codebase_paths = $o->codebase_paths;
     $this->db = $o->db;
     if ($o->page_path_default) {
         $this->page_path_default = $o->page_path_default;
     }
     if ($o->page_path_404) {
         $this->page_path_404 = $o->page_path_404;
     }
     $this->uri = $o->uri;
 }
开发者ID:HotwireCommunications,项目名称:skyphp,代码行数:19,代码来源:PageRouter.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_assoc_array函数代码示例发布时间:2022-05-15
下一篇:
PHP is_ascii函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap