本文整理汇总了PHP中mb_str_split函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_str_split函数的具体用法?PHP mb_str_split怎么用?PHP mb_str_split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mb_str_split函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: split1
function split1($s)
{
$l = 0;
$r = [""];
$j = strlen($s);
$m = false;
foreach (mb_str_split($s) as $c) {
/* TODO optimize */
if ($c == "\\" and !$m) {
$m = true;
continue;
}
if ($m and $c != "\\") {
$m = false;
if ($c == "|" and $l == 0) {
$r[] = "";
continue;
}
if ($c == "(" or $c == "[" or $c == "{") {
$l += 1;
} else {
if ($c == "}" or $c == "]" or $c == ")") {
$l -= 1;
}
}
$c = "\\{$c}";
}
array_push($r, array_pop($r) . $c);
//var_dump($r[count($r)-1]);
//var_dump($c);
}
return $r;
}
示例2: calculateAttributes
/**
* Calculates word's attributes.
*/
private function calculateAttributes()
{
$this->letterList = mb_str_split($this->word);
$this->length = mb_strlen($this->word, 'UTF-8');
$this->firstLetter = $this->letterList[0];
$this->lastLetter = $this->letterList[$this->length - 1];
}
示例3: test_mb_str_split
function test_mb_str_split()
{
$this->assertEquals(array('b', 'ö', 'b'), mb_str_split('böb'));
$this->assertEquals(array('bö', 'b'), mb_str_split('böb', 2));
for ($i = 1; $i < 10; $i++) {
$this->assertEquals(str_split('bob', $i), mb_str_split('bob', $i));
}
$this->assertEquals(str_split('bobby'), mb_str_split('bobby'));
$this->assertEquals(str_split(''), mb_str_split(''));
}
示例4: createRecords
/**
* Create records from a data string.
*
* @param string $data
*
* @return array(Record)
*/
public function createRecords($data)
{
$records = array();
$size = $this->settings->get('recordSize');
$compression = $this->settings->get('compression');
$dataEntries = mb_str_split($data, $size);
for ($i = 0, $len = sizeof($dataEntries); $i < $len; ++$i) {
$records[$i] = new Record($dataEntries[$i]);
$records[$i]->compress($compression);
}
return $records;
}
示例5: mb_ucwords
/**
* Multibyte version of ucwords().
*
* @param string $str
* @param string $delimiters
* @param null|string $encoding
*
* @return mixed|string
*/
function mb_ucwords($str, $delimiters = " \t\r\n\f\v", $encoding = null)
{
$encoding = Std::coalesce($encoding, mb_internal_encoding());
$delimitersArray = mb_str_split($delimiters, 1, $encoding);
$upper = true;
$result = '';
for ($ii = 0; $ii < mb_strlen($str, $encoding); $ii++) {
$char = mb_substr($str, $ii, 1, $encoding);
if ($upper) {
$char = mb_convert_case($char, MB_CASE_UPPER, $encoding);
$upper = false;
} elseif (ArrayList::of($delimitersArray)->includes($char)) {
$upper = true;
}
$result .= $char;
}
return $result;
}
示例6: file_matrix_1_6
/**
* 1.6 style file matrix
*
* @param string $filename The filename
*
* @return string
*/
function file_matrix_1_6($filename)
{
$invalid_fs_chars = '*\'\\/"!$%^&*.%(){}[]#~?<>;|¬`@-+=';
$matrix = "";
$name = $filename;
$filename = mb_str_split($filename);
if (!$filename) {
return false;
}
$len = count($filename);
if ($len > 5) {
$len = 5;
}
for ($n = 0; $n < $len; $n++) {
// Prevent a matrix being formed with unsafe characters
$char = $filename[$n];
if (strpos($invalid_fs_chars, $char) !== false) {
$char = '_';
}
$matrix .= $char . "/";
}
return $matrix . $name . "/";
}
示例7: trim
$text_size = 30;
# Limpio Lista de Glyphs
$made_from = trim($made_from);
// Trim
$made_from = mb_strtolower($made_from, 'UTF-8');
// Paso a Minusculas
$made_from = preg_replace('/\\s+/', '', $made_from);
// Borro Espacios en blanco
# Creo un Array limpito, con Frecuencia Zero
function mb_str_split($string)
{
return preg_split('/(?<!^)(?!$)/u', $string);
}
mb_internal_encoding('UTF-8');
// Modo UTF-8
$made_from = array_unique(mb_str_split($made_from));
$made_from = array_flip($made_from);
ksort($made_from);
foreach ($made_from as $key => $value) {
$made_from_as_array[$key] = 0;
}
# Funcion para buscar values que contengan una determinada string dentro de un array
function my_array_find($needle, $haystack)
{
foreach ($haystack as $item) {
if (strpos($item, $needle) !== FALSE) {
return $item;
break;
}
}
}
示例8: abs
$toprefix = "si";
}
// echo "s: " . $prefix_sci[$startprefix] ." t: ".$prefix_sci[$toprefix]. " | ";
if ((int) $prefix_sci[$startprefix] < (int) $prefix_sci[$toprefix]) {
// echo " [s < t] ". ($round+1) ."<br>";
$operation = "-";
$sumprefix = abs($prefix_sci[$startprefix] - $prefix_sci[$toprefix]);
}
if ((int) $prefix_sci[$startprefix] > (int) $prefix_sci[$toprefix]) {
// echo " [s > t] ". ($round+1) ."<br>";
$operation = "+";
$sumprefix = abs($prefix_sci[$toprefix] - $prefix_sci[$startprefix]);
}
// echo $sumprefix. ".. ";
//convert the start value to sci value
$startValueArr = mb_str_split($value);
//echo $value. " - ";
if ($value > 9) {
// echo "bigger than 9 } ";
while ((int) $value > 9) {
$value = $value / 10;
// echo $value. " - ";
$exponent++;
}
} else {
// echo "less than 1 } ";
while ((int) $value < 1) {
$value = $value * 10;
//echo $value. " - ";
$exponent--;
}
示例9: mysql_query
</tr>
</table>
';
}
echo ' <table border="1" cellspacing="0" style="width:100%; margin-top:10px;">';
$datos = mysql_query("SELECT a.nombre,a.id FROM horario h INNER JOIN materia m ON h.materia=m.id INNER JOIN area a ON m.area=a.id WHERE h.grupo='{$grupo}' AND h.anio='{$anio}' GROUP BY a.id ORDER BY a.nombre");
while ($reg = mysql_fetch_array($datos)) {
$area = $reg['id'];
$nomArea = $reg['nombre'];
echo '
<tr>
<td class="tdsAreas">
';
$nomArea = mb_strtoupper($nomArea, 'UTF-8');
$porciones = mb_str_split($nomArea);
for ($i = 0; $i < count($porciones); $i++) {
echo $porciones[$i] . "<br>";
}
echo '</td>
<td class="tdsInfoAreas">
<table cellspacing="0" border="1" style="width:100%;">';
$acomuladaArea = 0;
$datos2 = mysql_query("SELECT m.id,m.nombre, m.porcentaje FROM horario h INNER JOIN materia m ON h.materia=m.id INNER JOIN area a ON m.area=a.id WHERE h.grupo='{$grupo}' AND h.anio='{$anio}' AND a.id='{$area}' GROUP BY h.materia ORDER BY m.nombre");
while ($reg2 = mysql_fetch_array($datos2)) {
$materia = $reg2['id'];
$nomMateria = $reg2['nombre'];
$porcentajeMat = $reg2['porcentaje'];
$faltas = 0;
$datos3 = mysql_query("SELECT sum(falta) falta FROM faltas WHERE matricula='{$estInf}' AND materia='{$materia}' AND anio='{$anio}' ");
while ($reg3 = mysql_fetch_array($datos3)) {
示例10: split
public static function split($string, $at = '')
{
if (empty($at)) {
if (String::$multibyte) {
return new Arr(mb_str_split($string));
}
return new Arr(str_split($string));
}
return new Arr(explode($at, $string));
}
示例11: money_format
/**
* Money format
*
* @param mixed $amount
* @param array $options
* @return string
*/
public static function money_format($amount, $options = [])
{
$format = array_merge_hard(self::$options['locale_options'], $options['locale_options'] ?? []);
$options['decimals'] = $options['decimals'] ?? 2;
// sometimes symbols contain decimal point, we change it to thousands_sep
if (!empty($options['symbol'])) {
$options['symbol'] = str_replace($format['mon_decimal_point'], $format['mon_thousands_sep'], $options['symbol']);
} else {
$options['symbol'] = '';
}
// convert to string
if (!is_string($amount)) {
$amount = $amount . '';
}
$negative = strpos($amount, '-') !== false;
$amount = ltrim($amount, '-');
// if the number portion has been formatted
if (empty($options['amount_partially_formatted'])) {
$temp = explode('.', $amount);
$number = $temp[0];
$fraction = $temp[1] ?? '';
// process number
if (empty($number)) {
$number = '0';
}
if ($format['mon_thousands_sep'] . '' !== '' && !empty($format['mon_grouping'])) {
$counter = 0;
$mon_grouping = [];
$symbols = array_reverse(mb_str_split($number), true);
$number = '';
foreach ($symbols as $k => $v) {
// grab group size
if ($counter == 0) {
if (empty($mon_grouping)) {
$mon_grouping = $format['mon_grouping'];
}
if (count($mon_grouping) > 1) {
$counter = array_shift($mon_grouping);
} else {
$counter = $mon_grouping[0];
}
}
// skip number of characters
$counter--;
$number = $v . $number;
if ($counter == 0 && $k > 0) {
$number = $format['mon_thousands_sep'] . $number;
}
}
}
// left precision
if (!empty($options['digits'])) {
if (strlen($number) < $options['digits']) {
$number = str_pad($number, $options['digits'], ' ', STR_PAD_LEFT);
}
}
// right precision
if ($options['decimals'] > 0) {
$fraction = substr(str_pad($fraction, $options['decimals'], '0', STR_PAD_RIGHT), 0, $options['decimals']);
$number = $number . $format['mon_decimal_point'] . $fraction;
}
} else {
$number = $amount;
}
// translate characters
$number = self::number_to_from_native_language($number, $options);
// format based on settings
$cs_precedes = $negative ? $format['n_cs_precedes'] : $format['p_cs_precedes'];
$sep_by_space = $negative ? $format['n_sep_by_space'] : $format['p_sep_by_space'];
$sign_posn = $negative ? $format['n_sign_posn'] : $format['p_sign_posn'];
// if accounting formatting
if (!empty($options['accounting'])) {
// if we have currency symbol we added it based on settings
if (!empty($options['symbol'])) {
$number = ($cs_precedes ? $options['symbol'] . ($sep_by_space === 1 ? ' ' : '') : '') . $number . (!$cs_precedes ? ($sep_by_space === 1 ? ' ' : '') . $options['symbol'] : '');
}
if ($negative) {
$number = '(' . $number . ')';
} else {
$number = ' ' . $number . ' ';
}
} else {
$positive_sign = $format['positive_sign'];
$negative_sign = $format['negative_sign'];
$sign = $negative ? $negative_sign : $positive_sign;
$other_sign = $negative ? $positive_sign : $negative_sign;
$sign_padding = '';
if ($sign_posn) {
for ($i = 0; $i < strlen($other_sign) - strlen($sign); $i++) {
$sign_padding .= ' ';
}
}
$temp_value = '';
//.........这里部分代码省略.........
示例12: substr_count
$cuenta = substr_count($analizertwo, $letra);
if ($cuenta == 0) {
echo '<p style="color:red;">-</p>';
} else {
$frequency = round($cuenta * 100 / $total_letters, 1);
if ($frequency < 1) {
echo '<p style="color:red;">' . $frequency . '%</p>';
} else {
echo '<p>' . $frequency . '%</p>';
}
}
}
echo '</td>';
echo '<td valign="top">';
# Creo un Array limpito, con Frecuencia Zero
$made_from = array_unique(mb_str_split($analizertwo));
$new = my_array_find(' ', $made_from);
if (($key = array_search($new, $made_from)) !== false) {
unset($made_from[$key]);
}
$made_from = array_flip($made_from);
ksort($made_from);
foreach ($made_from as $key => $value) {
$made_from_as_array[$key] = 0;
}
foreach ($made_from_as_array as $letra => $occurencias) {
$made_from_as_array[$letra] = substr_count($analizertwo, $letra);
}
natsort($made_from_as_array);
echo '<pre>';
print_r($made_from_as_array);
示例13: DOMDocument
if ($user != 1 || $error == 1) {
$reason = "Error!";
$message = "There was an issue with your account... Please Login and try again";
$dom = new DOMDocument("1.0", "UTF-8");
$XML = $dom->appendChild($dom->createElement('error'));
$XML->setAttribute("xmlns:sql", "urn:schemas-microsoft-com:xml-sql");
$info = $XML->appendChild($dom->createElement('info'));
$info->setAttribute("code", "526.14");
$info->setAttribute("reason", $reason);
$info->setAttribute("message", $message);
$info->setAttribute("action", "None");
} else {
//Loads Armor String
$armors = $char['strArmor'];
//Converts string into Array
$split = mb_str_split($armors, 1);
//Sets New Value
$split[$index] = $newval;
//Combines Values
$i = 0;
while ($i <= 50) {
$newastr = $newastr . $split[$i];
$i++;
}
//Saves String to DB
$savestring = mysql_query("UPDATE df_characters SET strArmor='" . $newastr . "' WHERE ID='" . $char_id . "' LIMIT 1") or $error = 1;
if ($error == 1) {
$reason = "Error!";
$message = "Cannot save Armor Data.";
$dom = new DOMDocument("1.0", "UTF-8");
$XML = $dom->appendChild($dom->createElement('error'));
示例14: split
/**
* Split the string into smaller chunks.
*
* @param int $splitLength
*
* @return string[]
* @throws \Exception
*/
public function split($splitLength = 1)
{
return mb_str_split($this->contents, $splitLength, $this->encoding);
}
示例15: mb_strlen
?>
</h2>
</div>
<div style="float:right;">
<a href='player_games.php'><button class='btn btn-default btn-lg'>Δες όλα τα παιχνίδια</button></a>
</div>
</div>
<?php
// αν δεν υπάρχει το $_SESSION['word'], τότε διαλέγει λέξη και βάζει το επίπεδο δυσκολίας που επιλέχθηκε
if (!isset($_SESSION['word'])) {
include_once 'connect.php';
include_once 'choose_word.php';
$_SESSION['tries_left'] = $_SESSION['lives'];
$len = mb_strlen($word);
$_SESSION['word_array'] = mb_str_split($word);
//μετατροπή λέξης σε πίνακα χαρακτήρων
$print_word = array();
// ο παίκτης θα δει μόνο το πρώτο και το τελευταίο γράμμα της λέξης, τα ενδιάμεσα αντικαθίστανται από παύλες
$print_word[0] = $_SESSION['word_array'][0];
for ($i = 1; $i < $len - 1; $i++) {
$print_word[$i] = "_";
}
$print_word[$len - 1] = $_SESSION['word_array'][$len - 1];
$_SESSION['print_word'] = $print_word;
// δημιουργείται ο πίνακας με τα χρησιμοποιημένα γράμματα
$_SESSION['used'] = array();
}
if (isset($_POST['letter'])) {
// έλεγχος γράμματος
$_SESSION['used'][] = $_POST['letter'];