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

PHP substr_count函数代码示例

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

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



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

示例1: cut

 function cut($str, $limit, $more = " ...")
 {
     if ($str == "" || $str == NULL || is_array($str) || strlen($str) == 0) {
         return $str;
     }
     $str = trim($str);
     if (strlen($str) <= $limit) {
         return $str;
     }
     $str = substr($str, 0, $limit);
     if (!substr_count($str, " ")) {
         if ($more) {
             $str .= " ...";
         }
         return $str;
     }
     while (strlen($str) && $str[strlen($str) - 1] != " ") {
         $str = substr($str, 0, -1);
     }
     $str = substr($str, 0, -1);
     if ($more) {
         $str .= " ...";
     }
     return $str;
 }
开发者ID:JosTrucD,项目名称:phalcon-news,代码行数:25,代码来源:String.php


示例2: testIntrospectionContainsOperationForEachPrototypeOfAPublicMethod

 public function testIntrospectionContainsOperationForEachPrototypeOfAPublicMethod()
 {
     $xml = $this->introspector->introspect('com.zend.framework.IntrospectorTest');
     $this->assertEquals(4, substr_count($xml, 'name="foobar"'));
     $this->assertEquals(1, substr_count($xml, 'name="barbaz"'));
     $this->assertEquals(1, substr_count($xml, 'name="bazbat"'));
 }
开发者ID:netvlies,项目名称:zf,代码行数:7,代码来源:IntrospectorTest.php


示例3: testHtmlSpecialCharsInMessageGetEscapedForValidXml

 /**
  * @group ZF-2062
  * @group ZF-4190
  */
 public function testHtmlSpecialCharsInMessageGetEscapedForValidXml()
 {
     $f = new XmlFormatter();
     $line = $f->format(array('message' => '&key1=value1&key2=value2', 'priority' => 42));
     $this->assertContains("&amp;", $line);
     $this->assertTrue(substr_count($line, "&amp;") == 2);
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:11,代码来源:XmlTest.php


示例4: processPassThrough

 public static function processPassThrough($value)
 {
     // This function will parse the pass through data and populate and array with keys and values.
     // Passthrough format is key|value||key|value, etc.
     $passthrough_array = array();
     $cursor_pos = 0;
     $single_bar_pos = 0;
     $double_bar_pos = 0;
     // Find out how many key|value sets there are
     $single_bar_count = substr_count($value, '|');
     // loop passthrough data and add to array
     while ($cursor_pos < strlen($value)) {
         // position of the next single bar (end of key)
         $single_bar_pos = strpos($value, '|', $cursor_pos);
         // position of the next double bar (end of value)
         $double_bar_pos = strpos($value, '||', $cursor_pos);
         // at the end of the string the double bar will be absent and return false.
         // Then set the $double_bar_pos to the entire length of $value
         if ($double_bar_pos == false) {
             $double_bar_pos = strlen($value);
         }
         // set the key
         $array_key = substr($value, $cursor_pos, $single_bar_pos - $cursor_pos);
         // set the value
         $array_value = substr($value, $single_bar_pos + 1, $double_bar_pos - $single_bar_pos - 1);
         // move the cursor to the next key||value
         $cursor_pos = $double_bar_pos + 2;
         // add the key||value to the passthrough array
         $passthrough_array[$array_key] = $array_value;
     }
     // return the final passthrough array
     return $passthrough_array;
 }
开发者ID:jstramel,项目名称:ps_ivr,代码行数:33,代码来源:IfByPhone_Util.php


示例5: neat_r

function neat_r($arr, $return = false)
{
    $out = array();
    $oldtab = "    ";
    $newtab = "  ";
    $lines = explode("\n", print_r($arr, true));
    foreach ($lines as $line) {
        if (substr($line, -5) != "Array") {
            $line = preg_replace("/^(\\s*)\\[[0-9]+\\] => /", "\$1", $line, 1);
        }
        foreach (array("Array" => "", "[" => "", "]" => "", " =>" => ":") as $old => $new) {
            $out = str_replace($old, $new, $out);
        }
        if (in_array(trim($line), array("Array", "(", ")", ""))) {
            continue;
        }
        $indent = "\n";
        $indents = floor((substr_count($line, $oldtab) - 1) / 2);
        if ($indents > 0) {
            for ($i = 0; $i < $indents; $i++) {
                $indent .= $newtab;
            }
        }
        $out[] = $indent . trim($line);
    }
    $out = implode("<br/>", $out) . "\n";
    if ($return == true) {
        return $out;
    }
    echo $out;
}
开发者ID:sreeram77,项目名称:codejam,代码行数:31,代码来源:functions.php


示例6: replace_var_generic

function replace_var_generic($hardware_id, $url_group_server, $id_group = false)
{
    $count_add_ip = substr_count($url_group_server, '$IP$');
    $count_name = substr_count($url_group_server, '$NAME$');
    if ($count_add_ip > 0 or $count_name > 0) {
        $sql = "select IPADDR,NAME,ID from hardware where ID";
        if ($hardware_id != 'ALL') {
            $sql .= " = %s";
            $arg = $hardware_id;
        } else {
            $sql .= " in (select hardware_id from groups_cache where group_id = %s)";
            $arg = $id_group;
        }
        $resdefaultvalues = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg);
        while ($item = mysql_fetch_object($resdefaultvalues)) {
            $url_temp = str_replace('$IP$', $item->IPADDR, $url_group_server);
            $url[$item->ID] = str_replace('$NAME$', $item->NAME, $url_temp);
        }
    } elseif ($hardware_id != 'ALL') {
        $url[$hardware_id] = $url_group_server;
    } else {
        $sql = "select ID from hardware where ID";
        $sql .= " in (select hardware_id from groups_cache where group_id = %s)";
        $arg = $id_group;
        $resdefaultvalues = mysql2_query_secure($sql, $_SESSION['OCS']["readServer"], $arg);
        while ($item = mysql_fetch_object($resdefaultvalues)) {
            $url[$item->ID] = $url_group_server;
        }
    }
    return $url;
}
开发者ID:inkoss,项目名称:karoshi-server,代码行数:31,代码来源:function_server.php


示例7: writeBody

 function writeBody($message, $stream, &$length_raw, $boundary = '')
 {
     if ($boundary && !$message->rfc822_header) {
         $s = '--' . $boundary . "\r\n";
         $s .= $this->prepareMIME_Header($message, $boundary);
         $length_raw += strlen($s);
         if ($stream) {
             $this->preWriteToStream($s);
             $this->writeToStream($stream, $s);
         }
     }
     $this->writeBodyPart($message, $stream, $length_raw);
     $boundary_depth = substr_count($message->entity_id, '.');
     if ($boundary_depth) {
         $boundary .= '_part' . $boundary_depth;
     }
     $last = false;
     for ($i = 0, $entCount = count($message->entities); $i < $entCount; $i++) {
         $msg = $this->writeBody($message->entities[$i], $stream, $length_raw, $boundary);
         if ($i == $entCount - 1) {
             $last = true;
         }
     }
     if ($boundary && $last) {
         $s = "--" . $boundary . "--\r\n\r\n";
         $length_raw += strlen($s);
         if ($stream) {
             $this->preWriteToStream($s);
             $this->writeToStream($stream, $s);
         }
     }
 }
开发者ID:innomatic-libs,项目名称:squirrelmaillib,代码行数:32,代码来源:Deliver.class.php


示例8: ParseHeaderFooter

 private function ParseHeaderFooter($str, $uid = null)
 {
     $str = preg_replace_callback('/%sort_?link:([a-z0-9_]+)%/i', array(__CLASS__, 'GenSortlink'), $str);
     if (strpos($str, '%search_form%') !== false) {
         wpfb_loadclass('Output');
         $str = str_replace('%search_form%', WPFB_Output::GetSearchForm("", $_GET), $str);
     }
     $str = preg_replace_callback('/%print_?(script|style):([a-z0-9_-]+)%/i', array(__CLASS__, 'PrintScriptCallback'), $str);
     if (empty($uid)) {
         $uid = uniqid();
     }
     $str = str_replace('%uid%', $uid, $str);
     $count = 0;
     $str = preg_replace("/jQuery\\((.+?)\\)\\.dataTable\\s*\\((.*?)\\)(\\.?.*?)\\s*;/", 'jQuery($1).dataTable((function(options){/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/})($2))$3;', $str, -1, $count);
     if ($count > 0) {
         $dataTableOptions = array();
         list($sort_field, $sort_dir) = wpfb_call('Output', 'ParseSorting', $this->current_list->file_order);
         $file_tpl = WPFB_Core::GetTpls('file', $this->file_tpl_tag);
         if (($p = strpos($file_tpl, "%{$sort_field}%")) > 0) {
             // get the column index of field to sort
             $col_index = substr_count($file_tpl, "</t", 0, $p);
             $dataTableOptions["aaSorting"] = array(array($col_index, strtolower($sort_dir)));
         }
         if ($this->current_list->page_limit > 0) {
             $dataTableOptions["iDisplayLength"] = $this->current_list->page_limit;
         }
         $str = str_replace('/*%WPFB_DATA_TABLE_OPTIONS_FILTER%*/', " var wpfbOptions = " . json_encode($dataTableOptions) . "; " . " if('object' == typeof(options)) { for (var v in options) { wpfbOptions[v] = options[v]; } }" . " return wpfbOptions; ", $str);
     }
     return $str;
 }
开发者ID:parsonsc,项目名称:dofe,代码行数:30,代码来源:ListTpl.php


示例9: isIpv4

 /**
  * Checks if the ip is v4.
  *
  * @param string $ip IP to check
  *
  * @return bool return true if ipv4
  */
 public static function isIpv4($requestIp)
 {
     if (substr_count($requestIp, ':') > 1) {
         return false;
     }
     return true;
 }
开发者ID:cloudflare,项目名称:cf-ip-rewrite,代码行数:14,代码来源:IpUtils.php


示例10: addAdminScript

 public static function addAdminScript()
 {
     $checkJqueryLoaded = false;
     $document = JFactory::getDocument();
     $header = $document->getHeadData();
     JHTML::_('behavior.framework');
     if (!version_compare(JVERSION, '3.0', 'ge')) {
         foreach ($header['scripts'] as $scriptName => $scriptData) {
             if (substr_count($scriptName, '/jquery')) {
                 $checkJqueryLoaded = true;
             }
         }
         //Add js
         if (!$checkJqueryLoaded) {
             $document->addScript(JURI::root() . 'components/com_bt_socialconnect/assets/js/jquery.min.js');
         }
     }
     $document->addScript(JURI::root() . 'components/com_bt_socialconnect/assets/js/default.js');
     $document->addScript(JURI::root() . 'components/com_bt_socialconnect/assets/js/menu.js');
     $document->addScript(JURI::root() . 'administrator/components/com_bt_socialconnect/assets/js/bt_social.js');
     $document->addScriptDeclaration('jQuery.noConflict();');
     $document->addStyleSheet(JURI::root() . 'components/com_bt_socialconnect/assets/icon/admin.css');
     $document->addStyleSheet(JURI::root() . 'components/com_bt_socialconnect/assets/css/legacy.css');
     $document->addStyleSheet(JURI::root() . 'administrator/components/com_bt_socialconnect/assets/css/bt_social.css');
     if (!Bt_SocialconnectLegacyHelper::isLegacy()) {
         JHtml::_('formbehavior.chosen', 'select');
     }
 }
开发者ID:juanferden,项目名称:adoperp,代码行数:28,代码来源:helper.php


示例11: construct_ip_register_table

function construct_ip_register_table($ipaddress, $prevuserid, $depth = 1)
{
    global $vbulletin, $vbphrase;
    $depth--;
    if (VB_AREA == 'AdminCP') {
        $userscript = 'usertools.php';
    } else {
        $userscript = 'user.php';
    }
    if (substr($ipaddress, -1) == '.' or substr_count($ipaddress, '.') < 3) {
        // ends in a dot OR less than 3 dots in IP -> partial search
        $ipaddress_match = "ipaddress LIKE '" . $vbulletin->db->escape_string_like($ipaddress) . "%'";
    } else {
        // exact match
        $ipaddress_match = "ipaddress = '" . $vbulletin->db->escape_string($ipaddress) . "'";
    }
    $users = $vbulletin->db->query_read_slave("\n\t\tSELECT  userid, username, ipaddress\n\t\tFROM " . TABLE_PREFIX . "user AS user\n\t\tWHERE {$ipaddress_match} AND\n\t\t\tipaddress <> '' AND\n\t\t\tuserid <> {$prevuserid}\n\t\tORDER BY username\n\t");
    $retdata = '';
    while ($user = $vbulletin->db->fetch_array($users)) {
        $retdata .= '<li>' . "<a href=\"user.php?" . $vbulletin->session->vars['sessionurl'] . "do=" . iif(VB_AREA == 'ModCP', 'viewuser', 'edit') . "&amp;u={$user['userid']}\"><b>{$user['username']}</b></a> &nbsp;\n\t\t\t<a href=\"{$userscript}?" . $vbulletin->session->vars['sessionurl'] . "do=gethost&amp;ip={$user['ipaddress']}\" title=\"" . $vbphrase['resolve_address'] . "\">{$user['ipaddress']}</a> &nbsp; " . construct_link_code($vbphrase['find_posts_by_user'], "../search.php?" . $vbulletin->session->vars['sessionurl'] . "do=finduser&amp;u={$user['userid']}", '_blank') . construct_link_code($vbphrase['view_other_ip_addresses_for_this_user'], "{$userscript}?" . $vbulletin->session->vars['sessionurl'] . "do=doips&amp;u={$user['userid']}&amp;hash=" . CP_SESSIONHASH) . "</li>\n";
        if ($depth > 0) {
            $retdata .= construct_user_ip_table($user['userid'], $user['ipaddress'], $depth);
        }
    }
    if (empty($retdata)) {
        return '';
    } else {
        return '<ul>' . $retdata . '</ul>';
    }
}
开发者ID:holandacz,项目名称:nb4,代码行数:30,代码来源:adminfunctions_user.php


示例12: validation

 function validation($data, $files)
 {
     $errors = parent::validation($data, $files);
     // TODO - this reg expr can be improved
     if (!preg_match("/(\\(*\\s*\\bc\\d{1,2}\\b\\s*\\(*\\)*\\s*(\\(|and|or)\\s*)+\\(*\\s*\\bc\\d{1,2}\\b\\s*\\(*\\)*\\s*\$/i", $data['conditionexpr'])) {
         $errors['conditionexpr'] = get_string('badconditionexpr', 'block_configurable_reports');
     }
     if (substr_count($data['conditionexpr'], '(') != substr_count($data['conditionexpr'], ')')) {
         $errors['conditionexpr'] = get_string('badconditionexpr', 'block_configurable_reports');
     }
     if (isset($this->_customdata['elements']) && is_array($this->_customdata['elements'])) {
         $elements = $this->_customdata['elements'];
         $nel = count($elements);
         if (!empty($elements) && $nel > 1) {
             preg_match_all('/(\\d+)/', $data['conditionexpr'], $matches, PREG_PATTERN_ORDER);
             foreach ($matches[0] as $num) {
                 if ($num > $nel) {
                     $errors['conditionexpr'] = get_string('badconditionexpr', 'block_configurable_reports');
                     break;
                 }
             }
         }
     }
     return $errors;
 }
开发者ID:adonm,项目名称:learning,代码行数:25,代码来源:form.php


示例13: match_variable

 protected function match_variable($src)
 {
     $hash = [];
     while (preg_match("/({(\\\$[\$\\w][^\t]*)})/s", $src, $vars, PREG_OFFSET_CAPTURE)) {
         list($value, $pos) = $vars[1];
         if ($value == '') {
             break;
         }
         if (substr_count($value, '}') > 1) {
             for ($i = 0, $start = 0, $end = 0; $i < strlen($value); $i++) {
                 if ($value[$i] == '{') {
                     $start++;
                 } else {
                     if ($value[$i] == '}') {
                         if ($start == ++$end) {
                             $value = substr($value, 0, $i + 1);
                             break;
                         }
                     }
                 }
             }
         }
         $length = strlen($value);
         $src = substr($src, $pos + $length);
         $hash[sprintf('%03d_%s', $length, $value)] = $value;
     }
     krsort($hash, SORT_STRING);
     return $hash;
 }
开发者ID:tokushima,项目名称:ebi,代码行数:29,代码来源:TemplateVariable.php


示例14: parse_header

	public function parse_header($header) {
		$last_header = '';
		$parsed_header = array();
		for ($j = 0, $end = sizeof($header); $j < $end; $j++) {
			$hd = split(':', $header[$j], 2);
			
			if (preg_match_all("/\s/", $hd[0], $matches) || !isset($hd[1]) || !$hd[1]) {
				if ($last_header) {
					$parsed_header[$last_header] .= "\r\n" . trim($header[$j]);
				}
			} else {
				$last_header = strtolower($hd[0]);
				if (!isset($parsed_header[$last_header])) {
					$parsed_header[$last_header] = '';
				}
				$parsed_header[$last_header] .= (($parsed_header[$last_header]) ? "\r\n" : '') . trim($hd[1]);
			}
		}
		
		foreach ($parsed_header as $hd_name => $hd_content) {
			$start_enc_tag = $stop_enc_tag = 0;
			$pre_text = $enc_text = $post_text = "";
			
			while(1) {
				if (strstr($hd_content, '=?') && strstr($hd_content, '?=') && substr_count($hd_content,'?') > 3) {
					$start_enc_tag = strpos($hd_content, '=?');
					$pre_text = substr($hd_content, 0, $start_enc_tag);
					do {
						$stop_enc_tag = strpos($hd_content, '?=', $stop_enc_tag) + 2;
						$enc_text = substr($hd_content, $start_enc_tag, $stop_enc_tag);
					}
					while (!(substr_count($enc_text, '?') > 3));
					
					$enc_text = explode('?', $enc_text, 5);
					switch (strtoupper($enc_text[2])) {
						case "B":
							$dec_text = base64_decode($enc_text[3]);
							break;
						case "Q":
						default:
							$dec_text = quoted_printable_decode($enc_text[3]);
							$dec_text = str_replace('_', ' ', $dec_text);
							break;
					}
					
					$post_text = substr($hd_content, $stop_enc_tag);
					if (substr(ltrim($post_text), 0, 2) == '=?') {
						$post_text = ltrim($post_text);
					}
					
					$hd_content = $pre_text . $dec_text . $post_text;
					$parsed_header[$hd_name] = $hd_content;
				} else {
					break;
				}
			}
		}
		
		return $parsed_header;
	}
开发者ID:nopticon,项目名称:rockr,代码行数:60,代码来源:mail.php


示例15: link_library_modify_http_response

function link_library_modify_http_response($plugins_response)
{
    foreach ($plugins_response as $response_key => $plugin_response) {
        if (plugin_basename(__FILE__) == $plugin_response->plugin) {
            if (3 <= substr_count($plugin_response->new_version, '.')) {
                $plugin_info = get_plugin_data(__FILE__);
                $period_position = link_library_strposX($plugin_info['Version'], '.', 3);
                if (false !== $period_position) {
                    $current_version = substr($plugin_info['Version'], 0, $period_position);
                } else {
                    $current_version = $plugin_info['Version'];
                }
                $period_position2 = link_library_strposX($plugin_response->new_version, '.', 3);
                if (false !== $period_position) {
                    $new_version = substr($plugin_response->new_version, 0, $period_position2);
                } else {
                    $new_version = $plugin_response->new_version;
                }
                $version_diff = version_compare($current_version, $new_version);
                if (-1 < $version_diff) {
                    unset($plugins_response->{$response_key});
                }
            }
        }
    }
    return $plugins_response;
}
开发者ID:wenhao87,项目名称:WPPlugins,代码行数:27,代码来源:link-library.php


示例16: smarty_function_atktext

/**
 * function to get multilanguage strings
 *
 * This is actually a wrapper for ATK's atktext() method, for
 * use in templates.
 *
 * @author Ivo Jansch <[email protected]>
 *
 * Example: {atktext id="users.userinfo.description"}
 *          {atktext id="userinfo.description" module="users"}
 *          {atktext id="description" module="users" node="userinfo"}
 *
 */
function smarty_function_atktext($params, &$smarty)
{
    if (!isset($params["id"])) {
        $params["id"] = $params[0];
    }
    switch (substr_count($params["id"], ".")) {
        case 1:
            list($module, $id) = explode(".", $params["id"]);
            $str = atktext($id, $module, isset($params["node"]) ? $params["node"] : '');
            break;
        case 2:
            list($module, $node, $id) = explode(".", $params["id"]);
            $str = atktext($id, $module, $node);
            break;
        default:
            $str = atktext($params["id"], atkArrayNvl($params, "module", ""), atkArrayNvl($params, "node", ""), atkArrayNvl($params, "lng", ""));
    }
    if (isset($params["filter"])) {
        $fn = $params["filter"];
        $str = $fn($str);
    }
    // parse the rest of the params in the string
    atkimport("atk.utils.atkstringparser");
    $parser = new atkStringParser($str);
    return $parser->parse($params);
}
开发者ID:badpenguin,项目名称:atk-8,代码行数:39,代码来源:function.atktext.php


示例17: setItem

 /**
  * Set value of an item. 
  * 
  * @param  string      $path     system.common.global.sn or system.common.sn 
  * @param  string      $value 
  * @param  null|string $lang 
  * @access public
  * @return void
  */
 public function setItem($path, $value = '', $lang = null)
 {
     $level = substr_count($path, '.');
     $section = '';
     if ($level <= 1) {
         return false;
     }
     if ($level == 2) {
         list($owner, $module, $key) = explode('.', $path);
     }
     if ($level == 3) {
         list($owner, $module, $section, $key) = explode('.', $path);
     }
     $item = new stdclass();
     $item->owner = $owner;
     $item->module = $module;
     $item->section = $section;
     $item->key = $key;
     $item->value = $value;
     $clientLang = $this->app->getClientLang();
     $defaultLang = !empty($clientLang) ? $clientLang : 'zh-cn';
     $item->lang = $lang ? $lang : $defaultLang;
     $this->dao->replace(TABLE_CONFIG)->data($item)->exec();
     return !dao::isError();
 }
开发者ID:hansen1416,项目名称:eastsoft,代码行数:34,代码来源:model.php


示例18: getContentList

 public static function getContentList($params)
 {
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $groups = implode(',', $user->getAuthorisedViewLevels());
     //$matchtype  = $params->get('matchtype', 'all');
     $maximum = $params->get('maximum', 5);
     $tagsHelper = new JHelperTags();
     $option = $app->input->get('option');
     $view = $app->input->get('view');
     $prefix = $option . '.' . $view;
     $id = (array) $app->input->getObject('id');
     $selectedTag = $params->get('selected_tag');
     // Strip off any slug data.
     foreach ($id as $id) {
         if (substr_count($id, ':') > 0) {
             $idexplode = explode(':', $id);
             $id = $idexplode[0];
         }
     }
     $tagsToMatch = $selectedTag;
     if (!$tagsToMatch || is_null($tagsToMatch)) {
         return $results = false;
     }
     $query = $tagsHelper->getTagItemsQuery($tagsToMatch, $typesr = null, $includeChildren = false, $orderByOption = 'c.core_title', $orderDir = 'ASC', $anyOrAll = true, $languageFilter = 'all', $stateFilter = '0,1');
     $db->setQuery($query, 0, $maximum);
     $results = $db->loadObjectList();
     foreach ($results as $result) {
         $explodedAlias = explode('.', $result->type_alias);
         $result->link = 'index.php?option=' . $explodedAlias[0] . '&view=' . $explodedAlias[1] . '&id=' . $result->content_item_id . '-' . $result->core_alias;
     }
     return $results;
 }
开发者ID:AaronTRUngerboeck,项目名称:JoomlaTest,代码行数:34,代码来源:helper.php


示例19: decode

 public static function decode($input)
 {
     if (empty($input)) {
         return;
     }
     $paddingCharCount = substr_count($input, self::$map[32]);
     $allowedValues = array(6, 4, 3, 1, 0);
     if (!in_array($paddingCharCount, $allowedValues)) {
         return false;
     }
     for ($i = 0; $i < 4; $i++) {
         if ($paddingCharCount == $allowedValues[$i] && substr($input, -$allowedValues[$i]) != str_repeat(self::$map[32], $allowedValues[$i])) {
             return false;
         }
     }
     $input = str_replace('=', '', $input);
     $input = str_split($input);
     $binaryString = "";
     for ($i = 0; $i < count($input); $i = $i + 8) {
         $x = "";
         if (!in_array($input[$i], self::$map)) {
             return false;
         }
         for ($j = 0; $j < 8; $j++) {
             $x .= str_pad(base_convert(@self::$flippedMap[@$input[$i + $j]], 10, 2), 5, '0', STR_PAD_LEFT);
         }
         $eightBits = str_split($x, 8);
         for ($z = 0; $z < count($eightBits); $z++) {
             $binaryString .= ($y = chr(base_convert($eightBits[$z], 2, 10))) || ord($y) == 48 ? $y : "";
         }
     }
     return $binaryString;
 }
开发者ID:kraczo,项目名称:pracowniapizzy,代码行数:33,代码来源:base32.php


示例20: extract_columns

function extract_columns(&$columns, $file, $length)
{
    $fp = fopen($file, 'r');
    $index = 0;
    $z = 0;
    $mu = 0;
    $dmu = 0;
    while ($cols = fgetcsv($fp, 1024, ",")) {
        if (empty($cols[0])) {
            continue;
        }
        $pm_count = substr_count($cols[0], "±");
        if ($pm_count > 1) {
            $index += $pm_count - 1;
            $cols[0] = trim(skip($cols[0], " ", 4 * ($pm_count - 1)));
            echo $cols[0] . "\n";
        }
        if ($index == 1) {
            $z = $cols[0];
        }
        if ($index == 6) {
            $mu = (double) $cols[0];
            $dmu = trim(substr($cols[0], strpos($cols[0], "±") + 2));
        }
        if ($index >= $length - 1) {
            $index = 0;
            $columns[] = array($z, $mu, $dmu);
        } else {
            ++$index;
        }
    }
}
开发者ID:RichardTaillet,项目名称:Cosmologie,代码行数:32,代码来源:parse_csv.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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