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


PHP array_trim函数代码示例

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


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

示例1: array_trim

/**
 * 递归去除array中的空键
 */
function array_trim($array)
{
    $array = (array) $array;
    foreach ($array as $k => $v) {
        if ($v == '' || $v == array()) {
            unset($array[$k]);
        } elseif (is_array($v)) {
            $array[$k] = array_trim($v);
        }
    }
    return $array;
}
开发者ID:flyingfish2013,项目名称:Syssh,代码行数:15,代码来源:SS_array_helper.php

示例2: array_trim

/**
 * Trim all non-array values in an n-dimension array.
 */
function array_trim(&$arr)
{
    if (!is_array($arr)) {
        return false;
    }
    foreach ($arr as $key => $val) {
        if (is_array($val)) {
            array_trim($arr[$key]);
        } else {
            $arr[$key] = trim($arr[$key]);
        }
    }
}
开发者ID:nac80,项目名称:bijoux-admin,代码行数:16,代码来源:core_helper.php

示例3: storeSettingIpAddress

/**
 * This file is part of the Froxlor project.
 * Copyright (c) 2003-2009 the SysCP Team (see authors).
 * Copyright (c) 2010 the Froxlor Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.froxlor.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Florian Lippert <flo@syscp.org> (2003-2009)
 * @author     Froxlor team <team@froxlor.org> (2010-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Functions
 *
 */
function storeSettingIpAddress($fieldname, $fielddata, $newfieldvalue)
{
    $returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
    if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'ipaddress') {
        $mysql_access_host_array = array_map('trim', explode(',', Settings::Get('system.mysql_access_host')));
        $mysql_access_host_array[] = $newfieldvalue;
        $mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
        $mysql_access_host = implode(',', $mysql_access_host_array);
        correctMysqlUsers($mysql_access_host_array);
        Settings::Set('system.mysql_access_host', $mysql_access_host);
    }
    return $returnvalue;
}
开发者ID:cobrafast,项目名称:Froxlor,代码行数:29,代码来源:function.storeSettingIpAddress.php

示例4: parse

 function parse($caching = true)
 {
     $feed = new SimplePie();
     $feed->feed_url($this->uri);
     $feed->cache_location(SIMPLEPIE_CACHE_DIR);
     $feed->enable_caching($caching);
     // parse
     $parse_result = @$feed->init();
     if ($parse_result === false) {
         trigger_error("FeedParser::parse(): Failed to parse feed. uri: {$this->uri}", E_USER_NOTICE);
         return false;
     }
     $feed->handle_content_type();
     $link = $feed->get_feed_link();
     $channel = array('title' => $feed->get_feed_title(), 'link' => $link, 'uri' => $this->uri, 'last_modified' => SimplePie_Sanitize::parse_date($feed->data['last-modified']), 'description' => $feed->get_feed_description());
     // url
     $url = new Net_URL($feed->get_feed_link());
     $items = array();
     $feed_items = @$feed->get_items();
     if (is_array($feed_items)) {
         foreach ($feed_items as $item) {
             // category
             $categories = $item->get_category();
             if ($categories != '') {
                 $category = split(" ", $categories);
                 $category = array_trim($category);
             } else {
                 $category = '';
             }
             // author
             $author = '';
             if (is_array($authors = $item->get_authors())) {
                 $men = array();
                 foreach ($item->get_authors() as $man) {
                     $men[] = $man->get_name();
                 }
                 $author = join(', ', $men);
             }
             // description
             $description = $item->get_description();
             if (empty($description)) {
                 $description = '';
             }
             $items[] = array('title' => $item->get_title(), 'uri' => $item->get_permalink(), 'description' => $description, 'date' => $item->get_date('U'), 'author' => $author, 'category' => $category);
         }
     }
     $this->data = array('channel' => $channel, 'items' => $items);
     $this->parser =& $feed;
     unset($feed);
     return true;
 }
开发者ID:komagata,项目名称:plnet,代码行数:51,代码来源:FeedParser.php

示例5: str_replace_array

/**
 * Replaces Strings in an array, with the advantage that you
 * can select which fields should be str_replace'd
 *
 * @param mixed String or array of strings to search for
 * @param mixed String or array to replace with
 * @param array The subject array
 * @param string The fields which should be checked for, separated by spaces
 * @return array The str_replace'd array
 * @author Florian Lippert <flo@syscp.org>
 */
function str_replace_array($search, $replace, $subject, $fields = '')
{
    if (is_array($subject)) {
        $fields = array_trim(explode(' ', $fields));
        foreach ($subject as $field => $value) {
            if (!is_array($fields) || empty($fields) || is_array($fields) && !empty($fields) && in_array($field, $fields)) {
                $subject[$field] = str_replace($search, $replace, $subject[$field]);
            }
        }
    } else {
        $subject = str_replace($search, $replace, $subject);
    }
    return $subject;
}
开发者ID:HobbyNToys,项目名称:SysCP,代码行数:25,代码来源:function.str_replace_array.php

示例6: execute_document_ready

function execute_document_ready($l)
{
    $document_ready_exposed = document_ready(true);
    if ($document_ready_exposed != false) {
        $document_ready_exposed = explode(' ', $document_ready_exposed);
        $document_ready_exposed = array_unique($document_ready_exposed);
        $document_ready_exposed = array_trim($document_ready_exposed);
        foreach ($document_ready_exposed as $api_function) {
            if (function_exists($api_function)) {
                $l = $api_function($l);
            }
        }
    }
    return $l;
}
开发者ID:newaltcoin,项目名称:microweber,代码行数:15,代码来源:api.php

示例7: storeSettingMysqlAccessHost

/**
 * This file is part of the SysCP project.
 * Copyright (c) 2003-2009 the SysCP Team (see authors).
 *
 * For the full copyright and license information, please view the COPYING
 * file that was distributed with this source code. You can also view the
 * COPYING file online at http://files.syscp.org/misc/COPYING.txt
 *
 * @copyright  (c) the authors
 * @author     Florian Lippert <flo@syscp.org>
 * @license    GPLv2 http://files.syscp.org/misc/COPYING.txt
 *
 * @version    $Id$
 */
function storeSettingMysqlAccessHost($fieldname, $fielddata, $newfieldvalue)
{
    $returnvalue = storeSettingField($fieldname, $fielddata, $newfieldvalue);
    if ($returnvalue !== false && is_array($fielddata) && isset($fielddata['settinggroup']) && $fielddata['settinggroup'] == 'system' && isset($fielddata['varname']) && $fielddata['varname'] == 'mysql_access_host') {
        $mysql_access_host_array = array_map('trim', explode(',', $newfieldvalue));
        if (in_array('127.0.0.1', $mysql_access_host_array) && !in_array('localhost', $mysql_access_host_array)) {
            $mysql_access_host_array[] = 'localhost';
        }
        if (!in_array('127.0.0.1', $mysql_access_host_array) && in_array('localhost', $mysql_access_host_array)) {
            $mysql_access_host_array[] = '127.0.0.1';
        }
        $mysql_access_host_array = array_unique(array_trim($mysql_access_host_array));
        $newfieldvalue = implode(',', $mysql_access_host_array);
        correctMysqlUsers($mysql_access_host_array);
    }
    return $returnvalue;
}
开发者ID:markc,项目名称:syscp,代码行数:31,代码来源:function.storeSettingMysqlAccessHost.php

示例8: htmlentities_array

/**
 * Wrapper around htmlentities to handle arrays, with the advantage that you
 * can select which fields should be handled by htmlentities
 *
 * @param array The subject array
 * @param string The fields which should be checked for, separated by spaces
 * @param int See php documentation about this
 * @param string See php documentation about this
 * @return array The array with htmlentitie'd strings
 * @author Florian Lippert <flo@syscp.org>
 */
function htmlentities_array($subject, $fields = '', $quote_style = ENT_QUOTES, $charset = 'UTF-8')
{
    if (is_array($subject)) {
        if (!is_array($fields)) {
            $fields = array_trim(explode(' ', $fields));
        }
        foreach ($subject as $field => $value) {
            if (!is_array($fields) || empty($fields) || is_array($fields) && !empty($fields) && in_array($field, $fields)) {
                /**
                 * Just call ourselve to manage multi-dimensional arrays
                 */
                $subject[$field] = htmlentities_array($subject[$field], $fields, $quote_style, $charset);
            }
        }
    } else {
        $subject = htmlentities($subject, $quote_style, $charset);
    }
    return $subject;
}
开发者ID:cobrafast,项目名称:Froxlor,代码行数:30,代码来源:function.htmlentities_array.php

示例9: array_clean

/** function array_clean [arrayClean]
 *		Strips out the unnecessary bits from an array
 *		so it can be input into a database, or to just
 *		generally clean an array of fluff
 *
 * @param array data array to be cleaned
 * @param mixed csv or array of allowed keys
 * @param mixed optional csv or array of required keys
 * @return array
 */
function array_clean($array, $keys, $reqd = array())
{
    if (!is_array($array)) {
        return array();
    }
    array_trim($keys);
    if (0 == count($keys)) {
        throw new MyException(__FUNCTION__ . ': No keys given');
    }
    array_trim($reqd);
    $return = array();
    foreach ($keys as $key) {
        if (in_array($key, $reqd) && empty($array[$key])) {
            throw new MyException(__FUNCTION__ . ': Required element (' . $key . ') missing');
        }
        if (isset($array[$key])) {
            $return[$key] = $array[$key];
        }
    }
    return $return;
}
开发者ID:benjamw,项目名称:quarto,代码行数:31,代码来源:func.array.php

示例10: array_clean

/** function array_clean [arrayClean]
 *		Strips out the unnecessary bits from an array
 *		so it can be input into a database, or to just
 *		generally clean an array of fluff
 *
 * @param array $array data array to be cleaned
 * @param mixed $keys csv or array of allowed keys
 * @param mixed $required optional csv or array of required keys
 *
 * @return array
 * @throws MyException
 */
function array_clean($array, $keys, $required = array())
{
    if (!is_array($array)) {
        return array();
    }
    array_trim($keys);
    array_trim($required);
    $keys = array_unique(array_merge($keys, $required));
    if (empty($keys)) {
        return array();
    }
    $return = array();
    foreach ($keys as $key) {
        if (in_array($key, $required) && empty($array[$key])) {
            throw new MyException(__FUNCTION__ . ': Required element (' . $key . ') missing');
        }
        if (isset($array[$key])) {
            $return[$key] = $array[$key];
        }
    }
    return $return;
}
开发者ID:studywithyou,项目名称:webrisk,代码行数:34,代码来源:func.array.php

示例11: stripslashes_array

/**
 * Wrapper around stripslashes to handle arrays, with the advantage that you
 * can select which fields should be handled by htmlentities and with advantage,
 * that you can eliminate all slashes by setting complete=true
 *
 * @param array The subject array
 * @param int See php documentation about this
 * @param string See php documentation about this
 * @param string The fields which should be checked for, separated by spaces
 * @param bool Select true to use stripslashes_complete instead of stripslashes
 * @return array The array with stripslashe'd strings
 * @author Florian Lippert <flo@syscp.org>
 */
function stripslashes_array($subject, $fields = '', $complete = false)
{
    if (is_array($subject)) {
        if (!is_array($fields)) {
            $fields = array_trim(explode(' ', $fields));
        }
        foreach ($subject as $field => $value) {
            if (!is_array($fields) || empty($fields) || is_array($fields) && !empty($fields) && in_array($field, $fields)) {
                /**
                 * Just call ourselve to manage multi-dimensional arrays
                 */
                $subject[$field] = stripslashes_array($subject[$field], $fields, $complete);
            }
        }
    } else {
        if ($complete == true) {
            $subject = stripslashes_complete($subject);
        } else {
            $subject = stripslashes($subject);
        }
    }
    return $subject;
}
开发者ID:HobbyNToys,项目名称:SysCP,代码行数:36,代码来源:function.stripslashes_array.php

示例12: update_password

 public function update_password($data, $id)
 {
     if (array_valid($data) && is_valid_id($id)) {
         // Ensure no bogus whitespace on any of the information
         array_trim($data);
         // Let's be sure the passwords match
         $new_password = $data['magickey'];
         $match_password = $data['matchkey'];
         if ($new_password === $match_password) {
             $update_data['magickey'] = sha1($new_password);
             $this->db->where('id', $id);
             $this->db->update('user', $update_data);
             return TRUE;
         } else {
             $errors[] = 'The passwords for both fields did not match, please try again';
         }
     } else {
         $errors[] = 'No user information was provided';
     }
     if (array_valid($errors)) {
         return $errors;
     }
 }
开发者ID:nac80,项目名称:bijoux-admin,代码行数:23,代码来源:user_model.php

示例13: html_entity_decode_array

/**
 * Wrapper around html_entity_decode to handle arrays, with the advantage that you
 * can select which fields should be handled by htmlentities and with advantage,
 * that you can eliminate all html entities by setting complete=true
 *
 * @param array The subject array
 * @param string The fields which should be checked for, separated by spaces
 * @param bool Select true to use html_entity_decode_complete instead of html_entity_decode
 * @param int See php documentation about this
 * @param string See php documentation about this
 * @return array The array with html_entity_decode'd strings
 * @author Florian Lippert <flo@syscp.org>
 */
function html_entity_decode_array($subject, $fields = '', $complete = false, $quote_style = ENT_COMPAT, $charset = 'ISO-8859-1')
{
    if (is_array($subject)) {
        if (!is_array($fields)) {
            $fields = array_trim(explode(' ', $fields));
        }
        foreach ($subject as $field => $value) {
            if (!is_array($fields) || empty($fields) || is_array($fields) && !empty($fields) && in_array($field, $fields)) {
                /**
                 * Just call ourselve to manage multi-dimensional arrays
                 */
                $subject[$field] = html_entity_decode_array($subject[$field], $fields, $complete, $quote_style, $charset);
            }
        }
    } else {
        if ($complete == true) {
            $subject = html_entity_decode_complete($subject, $quote_style, $charset);
        } else {
            $subject = html_entity_decode($subject, $quote_style, $charset);
        }
    }
    return $subject;
}
开发者ID:Alkyoneus,项目名称:Froxlor,代码行数:36,代码来源:function.html_entity_decode_array.php

示例14: array_trim

/**
 * @example
 * $value = [
 *     'a' => [
 *         'b' => [],
 *     ],
 *     'c' => [
 *         'd' => [
 *             'e' => 1,
 *         ],
 *     ],
 * ];
 *
 * // [
 * //     'c' => [
 * //         'd' => [
 * //             'e' => 1,
 * //         ],
 * //     ],
 * // ];
 * $value = \Owl\array_trim($value);
 */
function array_trim(array $target)
{
    $keys = array_keys($target);
    $is_array = $keys === array_keys($keys);
    $result = [];
    foreach ($target as $key => $value) {
        if (is_array($value) && $value) {
            $value = array_trim($value);
        }
        if ($value === null || $value === '' || $value === []) {
            continue;
        }
        $result[$key] = $value;
    }
    if ($is_array && $result) {
        $result = array_values($result);
    }
    return $result;
}
开发者ID:yeaha,项目名称:owl-core,代码行数:41,代码来源:functions.php

示例15: array_trim

                                <td>
                                	<input type='text' name='dfinal_dia' maxlength="2" size="2" />&nbsp;/
                                    <input type='text' name='dfinal_mes' maxlength="2" size="2" />&nbsp;/
                                    <input type='text' name='dfinal_ano' maxlength="4" size="4" />
								</td>
                            </tr>
							<tr>
                                <td colspan="2" class="bottom_row">
                                	<input type='submit' value='Pesquisar' />
                                </td>
                            </tr>
                        </table>
                        </form>
					<?php 
        } else {
            $_POST = array_trim($_POST);
            $data_inicial = implode('-', array($_POST['dinicial_ano'], $_POST['dinicial_mes'], $_POST['dinicial_dia']));
            $data_final = implode('-', array($_POST['dfinal_ano'], $_POST['dfinal_mes'], $_POST['dfinal_dia']));
            $c = new conexao();
            $c->set_charset('utf8');
            $q = "SELECT a.nome, b.* FROM usuarios AS a INNER JOIN logs AS b ON a.id = b.usuario_id WHERE horario BETWEEN '{$data_inicial}' AND '{$data_final}';";
            $r = $c->query($q);
            ?>
                    	<h2>Mostrando registros entre (<?php 
            echo $data_inicial;
            ?>
) e (<?php 
            echo $data_final;
            ?>
)</h2>
                    	<table class="content_table">
开发者ID:NAILIWB,项目名称:hstock,代码行数:31,代码来源:logs.php


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