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


PHP array_key函数代码示例

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


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

示例1: render

 public function render(ddUploadify $up)
 {
     $widget_id = $this->getSlug() . '-input';
     $form = new BaseForm();
     $csrf_token = $form->getCSRFToken();
     $output = '<div class="container dd-img-upload-wrapper">';
     $output .= '<div id="fileQueue"></div>';
     $output .= '<input type="file" name="' . $up->getSlug() . '" id="' . $widget_id . '" />';
     $output .= '<p><a href="javascript:jQuery(\'#' . $widget_id . '\').uploadifyClearQueue()">Cancel All Uploads</a></p>';
     $output .= '<div class="swfupload-buttontarget">
     <noscript>
       We\'re sorry.  SWFUpload could not load.  You must have JavaScript enabled to enjoy SWFUpload.
     </noscript>
   </div>';
     $output .= '<script type="text/javascript">
     //<![CDATA[
     $(document).ready(function() {
       $(\'#' . $widget_id . ' \').uploadify({
         \'scriptData\': {\' ' . array_key($up->getSession()) . ' \': \' ' . array_value($up->getSession()) . ' \', \'_csrf_token\': \' ' . $csrf_token . ' \'},
         \'uploader\': \' ' . $up->getUploader() . ' \',
         \'cancelImg\': \'cancel.png\',
         \'auto\'      : true,
         \'script\': $(\'#' . $widget_id . '\').closest(\'form\').attr(\'action\')+\'/upload\',
         \'folder\': \'\',
         \'multi\': false,
         \'displayData\': \'speed \',
         \'fileDataName\': \' ' . $widget_id . ' \',
         \'simUploadLimit\': 2
       });
     });
     //]]>
   </script>';
     printf($output);
 }
开发者ID:ner0tic,项目名称:scss,代码行数:34,代码来源:ddUploadifyRenderer.class.php

示例2: from_xml

 /**
  * Decode the XML type and return data
  *
  * @param String $text the text to decode
  * @param String $root the root element name (default is "root")
  * @return Array the decoded data as an assoc array
  */
 public static function from_xml($text, $root = Symbol::ROOT)
 {
     load_tool('XML');
     $data = object_to_array(XML::deserialize($text));
     return array_key($data, $root, $data);
     // skip the root element
 }
开发者ID:hutchike,项目名称:YAWF,代码行数:14,代码来源:Data.php

示例3: to_text

 public function to_text()
 {
     $notes = $this->to_array();
     $list = array();
     foreach ($notes as $id => $note) {
         if (array_key($note, 'deleted')) {
             continue;
         }
         $x = array_key($note, 'x', 0);
         $line = sprintf('%02d', intval(array_key($note, 'y', 0) / 41));
         $text = array_key($note, 'text', '');
         $list[$line . $x / 1000] = $text;
     }
     ksort($list);
     $note = '';
     $last_pos = 0;
     foreach ($list as $pos => $text) {
         $nl = str_repeat("\n", intval($pos / 10) - intval($last_pos / 10));
         if ($note) {
             $note .= intval($pos) == intval($last_pos) ? ' ' : $nl;
         }
         $note .= $text;
         $last_pos = $pos;
     }
     return $note;
 }
开发者ID:hutchike,项目名称:notex,代码行数:26,代码来源:Note.php

示例4: details

 public static function details($user_agent)
 {
     if (is_null(self::$browscap)) {
         $cache_dir = self::BROWSCAP_CACHE_DIR;
         if (!is_dir($cache_dir)) {
             mkdir($cache_dir);
         }
         self::$browscap = new Browscap($cache_dir);
     }
     // Reset the user agents cache if we've cached too many
     if (count(self::$user_agents) > self::MAX_USER_AGENTS_COUNT) {
         self::$user_agents = array();
     }
     // If user agent info is cached then return it
     if ($details = array_key(self::$user_agents, $user_agent)) {
         return $details;
     }
     // Look up the user agent using the browscap.ini file
     $browscap = self::$browscap->getBrowser($user_agent, TRUE);
     $browser = array_key($browscap, 'Browser');
     // e.g. "IE"
     $version = array_key($browscap, 'Parent');
     // e.g. "IE 9.0"
     $version = $version && $browser && strpos($version, $browser) === 0 ? substr($version, strlen($browser) + 1) : $version;
     $op_sys = array_key($browscap, 'Platform');
     $is_mobile = array_key($browscap, 'isMobileDevice');
     $details = array('op_sys' => $op_sys, 'browser' => $browser, 'version' => $version, 'browser_version' => $browser . ($version ? " {$version}" : ''), 'is_robot' => $op_sys == 'unknown' ? TRUE : FALSE, 'is_mobile' => $is_mobile);
     return self::$user_agents[$user_agent] = new Object($details);
 }
开发者ID:hutchike,项目名称:YAWF,代码行数:29,代码来源:UserAgent.php

示例5: parse_code

 /**
  * Parse a country code by turning 3-chars into 2-chars (in uppercase)
  *
  * @param String $code the country code to parse
  * @return String the parsed country code (2-chars in uppercase or NULL)
  */
 private static function parse_code($code)
 {
     $code = strtoupper($code);
     if (strlen($code) == 3) {
         $code = array_key(self::$trans, $code);
     }
     return $code;
 }
开发者ID:hutchike,项目名称:YAWF,代码行数:14,代码来源:Country.php

示例6: make

 /**
  * Make a new model object, optionally with some initialization data
  *
  * @param String $model the name of the model class to make
  * @param Array $data an optional array of initialization data
  * @param Boolean $has_changed whether the newly made object has changed
  * @return SQL_model/Remote the newly made model object or its remote object
  */
 public static function make($model, $data = array(), $has_changed = TRUE)
 {
     load_model($model);
     $object = new $model($data, $has_changed);
     if (array_key(self::$is_remote, Symbol::ALL) || array_key(self::$is_remote, $model)) {
         $object = new Remote($object);
     }
     return $object;
 }
开发者ID:hutchike,项目名称:YAWF,代码行数:17,代码来源:Remoting_model.php

示例7: render_view

 /**
  * Variation of the regular "render_view" that can insert test results
  *
  * @param String $file blah
  * @param Object $render data to render in the view
  * @param Array $options an array of rendering options (optional)
  * @return String the contents to send in response to the client
  */
 public function render_view($file, $render = NULL, $options = array())
 {
     $render = new Object($render);
     if (array_key($options, Symbol::FOLDER) === 'types' && array_key($_SERVER, 'REMOTE_ADDR')) {
         // to check it's a web request
         $this->render_test_run($render);
     }
     return parent::render_view($file, $render, $options);
 }
开发者ID:hutchike,项目名称:YAWF,代码行数:17,代码来源:App_test.php

示例8: from

	public function from($address) {
		if (strpos($address, '@') === false) {
			global $config;

			$address = $config['sitename'] . ' <' . $address . '@' . array_key(explode('@', $config['board_email']), 1) . '>';
		}

		$this->from = trim($address);
	}
开发者ID:nopticon,项目名称:rockr,代码行数:9,代码来源:emailer.php

示例9: buildExpand

 /**
  * @param array $joins
  * @param array $params the binding parameters to be populated
  * @return string the JOIN clause built from [[Query::$join]].
  * @throws Exception if the $joins parameter is not in proper format
  */
 public function buildExpand($joins)
 {
     $expands = [];
     if (is_array($joins)) {
         foreach ($joins as $item) {
             $expands[] = is_array($item) ? array_key($item) : $item;
         }
     }
     return ['expand' => implode(',', $joins)];
 }
开发者ID:bruno-melo,项目名称:components,代码行数:16,代码来源:RequestBuilder.php

示例10: into

 /**
  * Translate a word into a language, optionally with replacements
  * for example "array('NAME', $user->name)" would insert the name.
  *
  * @param String $lang the language to translate into
  * @param String $lookup the string to lookup in the translations
  * @param Array $replacements an optional array of replacements to make
  * @return String the translated string in the chosen language
  */
 public static function into($lang, $lookup, $replacements = array())
 {
     $text = array_key(self::$translations[$lang], strtolower($lookup));
     if (is_null($text)) {
         throw new Exception("Translation missing for {$lookup} in '{$lang}'");
     }
     foreach ($replacements as $find => $replace) {
         $text = str_replace($find, $replace, $text);
     }
     return $text;
 }
开发者ID:hutchike,项目名称:YAWF,代码行数:20,代码来源:Translate.php

示例11: in

    public function in()
    {
        global $user, $core;
        if ($user->v('is_member')) {
            redirect(_link());
        }
        if (_button()) {
            $v = $this->__(w('username password lastpage'));
            $userdata = w();
            if (!f($v['username']) || !f($v['password']) || !preg_match('#^([a-z0-9\\_\\-]+)$#is', $v['username'])) {
                $this->error('LOGIN_ERROR');
            }
            if (!$this->errors()) {
                $v['username'] = array_key(explode('@', $v['username']), 0);
                $sql = 'SELECT *
					FROM _members
					WHERE user_username = ?
						AND user_id <> ?
						AND user_active = 1';
                if (!($userdata = _fieldrow(sql_filter($sql, $v['username'], U_GUEST)))) {
                    $this->error('LOGIN_ERROR');
                }
                if (!$this->errors()) {
                    if (!$core->v('signin_pop')) {
                        if (isset($userdata['user_password']) && $userdata['user_password'] === _password($v['password'])) {
                            $user->session_create($userdata['user_id']);
                            redirect($v['lastpage']);
                        }
                        $this->error('LOGIN_ERROR');
                    } else {
                        require_once XFS . 'core/pop3.php';
                        $pop3 = new pop3();
                        if (!$pop3->connect($core->v('mail_server'), $core->v('mail_port'))) {
                            $this->error('LOGIN_ERROR');
                        }
                        if (!$this->errors() && !$pop3->user($v['username'])) {
                            $this->error('LOGIN_ERROR');
                        }
                        if (!$this->errors() && !$pop3->pass($v['password'], false)) {
                            $this->error('LOGIN_ERROR');
                        }
                        $pop3->quit();
                        if (!$this->errors()) {
                            $user->session_create($userdata['user_id']);
                            redirect($v['lastpage']);
                        }
                    }
                }
            }
        }
        _login(false, $this->get_errors());
    }
开发者ID:nopticon,项目名称:noptc,代码行数:52,代码来源:_sign.php

示例12: __construct

    public function __construct()
    {
        $sql = 'SELECT *
			FROM _config';
        $this->config = sql_rowset($sql, 'config_name', 'config_value');
        if ($this->v('site_disable')) {
            exit('not_running');
        }
        $address = $this->v('site_address');
        $host_addr = array_key(explode('/', array_key(explode('//', $address), 1)), 0);
        if ($host_addr != get_host()) {
            $allow_hosts = get_file(XFS . XCOR . 'store/domain_alias');
            foreach ($allow_hosts as $row) {
                if (substr($row, 0, 1) == '#') {
                    continue;
                }
                $remote = strpos($row, '*') === false;
                $row = !$remote ? str_replace('*', '', $row) : $row;
                $row = str_replace('www.', '', $row);
                if ($row == get_host()) {
                    $sub = str_replace($row, '', get_host());
                    $sub = f($sub) ? $sub . '.' : ($remote ? 'www.' : '');
                    $address = str_replace($host_addr, $sub . $row, $address);
                    $this->v('site_address', $address, true);
                    break;
                }
            }
        }
        if (strpos($address, 'www.') !== false && strpos(get_host(), 'www.') === false && strpos($address, get_host())) {
            $page_protocol = array_key(explode('//', _page()), 0);
            $a = $this->v('site_address') . str_replace(str_replace('www.', '', $page_protocol . $address), '', _page());
            redirect($a, false);
        }
        $this->cache_dir = XFS . XCOR . 'cache/';
        if (is_remote() && @file_exists($this->cache_dir) && @is_writable($this->cache_dir) && @is_readable($this->cache_dir)) {
            $this->cache_f = true;
        }
        //
        // Load additional objects.
        //
        $this->email = _import('emailer');
        $this->cache = _import('cache');
        return;
    }
开发者ID:nopticon,项目名称:npt,代码行数:44,代码来源:core.php

示例13: before

 public function before()
 {
     // Setup extra configuration, e.g. Twitter
     $config = Config::load('notex');
     Config::define_constants($config['twitter']);
     Config::define_constants($config['notes']);
     // Setup global variables and rendering data
     $uri = $_SERVER['REQUEST_URI'];
     $this->render->username = $this->username = $this->username_from_host();
     $this->render->screen_name = $this->screen_name = Twitter::screen_name($this->session->access_token);
     $this->render->is_owner = $this->is_owner = $this->screen_name && $this->screen_name == $this->username;
     $this->render->copy = '';
     $this->render->debug = '';
     $this->render->layout = 'notepad';
     $this->host_ip = array_key($_SERVER, 'HTTP_X_FORWARDED_FOR', $_SERVER['REMOTE_ADDR']);
     $title = ($this->username ? $this->username . '.' : '') . 'noted.cc';
     $title .= $uri == '/' ? ' | web notepad' : $uri;
     $this->render->title = $title;
     // Handle alternative content types, e.g. XML and JSON
     $type = $this->app->get_content_type();
     if ($type != 'html') {
         $this->respond_with_data_as($type);
     }
 }
开发者ID:hutchike,项目名称:notex,代码行数:24,代码来源:App.php

示例14: process

 public function process($pParams)
 {
     extract($pParams);
     //are there any values given ?
     if (empty($values)) {
         throw new CopixTemplateTagException("[plugin CSV] parameter 'values' cannot be empty");
         return;
     }
     //checking if values is an array
     if (!is_array($values)) {
         throw new CopixTemplateTagException("[plugin CSV] parameter 'values' must be an array");
         return;
     }
     //checinkg if value is an array of object or an array of array.
     if (count($values) <= 0) {
         $output = '';
     } else {
         $first = $values[0];
         if (is_object($first)) {
             $objectMode = true;
         } elseif (is_array($first)) {
             $objectMode = false;
         } else {
             throw new CopixTemplateTagException("[plugin CSV] parameter 'values' must be an array of object or an array of array");
         }
     }
     //the separator
     if (!(isset($separator) && is_string($separator))) {
         $separator = ',';
     }
     //no values ? empty output.
     if (count($values) <= 0) {
         $output = '';
     } else {
         $firstRow = $values[0];
         if (is_object($firstRow)) {
             $objectMode = true;
         } elseif (is_array($firstRow)) {
             $objectMode = false;
         } else {
             throw new CopixTemplateTagException("[plugin CSV] parameter 'values' must be an array of object or an array of associative array");
         }
     }
     //calculating headers.
     if (!empty($displayHeaders) && $displayHeaders) {
         if ($objectMode) {
             $headers = get_object_vars($firstRow);
         } else {
             $headers = array_key($firstRow);
         }
         $output .= implode($separator, $headers) . "\n";
     }
     //exporting values into csv
     foreach ($values as $rowNumber => $rowValues) {
         $rowValues = $objectMode ? array_values(get_object_vars($rowValues)) : array_values($rowValues);
         $output .= implode($separator, $rowValues) . "\n";
     }
     //now sorting elements.
     //TODO.
     return $output;
 }
开发者ID:JVS-IS,项目名称:ICONITO-EcoleNumerique,代码行数:61,代码来源:csv.templatetag.php

示例15: is_serialized

 /**
  * Return whether a session key is serialized (and optionally set this flag)
  *
  * @param String $key the session key
  * @param Boolean $is_serialized the flag's setting (optional)
  * @return Boolean whether or not the session key is serialized
  */
 public function is_serialized($key, $is_serialized = NULL)
 {
     $flag = '__' . $key;
     if (is_bool($is_serialized)) {
         return $this->session[$flag] = $is_serialized;
     } else {
         return array_key($this->session, $flag) ? TRUE : FALSE;
     }
 }
开发者ID:hutchike,项目名称:YAWF,代码行数:16,代码来源:Request.php


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