本文整理汇总了PHP中str_split函数的典型用法代码示例。如果您正苦于以下问题:PHP str_split函数的具体用法?PHP str_split怎么用?PHP str_split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_split函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getToken
function getToken($table, $campo, $uc = TRUE, $n = TRUE, $sc = TRUE, $largo = 15)
{
$db = new db_core();
$source = 'abcdefghijklmnopqrstuvwxyz';
if ($uc == 1) {
$source .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
}
if ($n == 1) {
$source .= '1234567890';
}
if ($sc == 1) {
$source .= '|@#~$%()=^*+[]{}-_';
}
$rstr = "";
while (true) {
$rstr = "";
$source = str_split($source, 1);
for ($i = 1; $i <= $largo; $i++) {
mt_srand((double) microtime() * 1000000);
$num = mt_rand(1, count($source));
$rstr .= $source[$num - 1];
}
if (!$db->isExists($table, $campo, $rstr)) {
break;
}
}
return $rstr;
}
开发者ID:centaurustech,项目名称:eollice,代码行数:28,代码来源:webservice.php
示例2: index_onMigrateFlyers
public function index_onMigrateFlyers($save = true)
{
$migrated = $unmigrated = $added = $skipped = $ignored = 0;
// Load a batch of unmigrated flyers
$unmigrated = FlyerModel::with('legacyImage')->has('image', 0)->count();
$flyers = FlyerModel::with('legacyImage')->has('image', 0)->limit(100)->get();
$migrated = $flyers->count();
// Migrate
foreach ($flyers as $flyer) {
$legacyImage = $flyer->legacyImage;
// Too old?
if (!$legacyImage->file) {
$skipped++;
continue;
}
$dir = str_split(sprintf('%08x', (int) $legacyImage->id), 2);
array_pop($dir);
$dir = implode('/', $dir);
$path = 'migrate/' . $dir . '/' . $legacyImage->file;
// Original file not found?
if (!file_exists($path)) {
$ignored++;
continue;
}
if ($save) {
$flyer->image()->create(['data' => $path]);
$added++;
}
}
$this->vars['added'] = $added;
$this->vars['ignored'] = $ignored;
$this->vars['skipped'] = $skipped;
$this->vars['migrated'] = $migrated;
$this->vars['unmigrated'] = $unmigrated;
}
开发者ID:anqqa,项目名称:oc-gallery-plugin,代码行数:35,代码来源:Migrate.php
示例3: convBase
function convBase($numberInput, $fromBaseInput, $toBaseInput)
{
if ($fromBaseInput == $toBaseInput) {
return $numberInput;
}
$fromBase = str_split($fromBaseInput, 1);
$toBase = str_split($toBaseInput, 1);
$number = str_split($numberInput, 1);
$fromLen = strlen($fromBaseInput);
$toLen = strlen($toBaseInput);
$numberLen = strlen($numberInput);
$retval = '';
$base10 = '';
if ($toBaseInput == '0123456789') {
$retval = 0;
for ($i = 1; $i <= $numberLen; $i++) {
$retval = bcadd($retval, bcmul(array_search($number[$i - 1], $fromBase), bcpow($fromLen, $numberLen - $i)));
}
return $retval;
}
if ($fromBaseInput != '0123456789') {
$base10 = convBase($numberInput, $fromBaseInput, '0123456789');
} else {
$base10 = $numberInput;
}
if ($base10 < strlen($toBaseInput)) {
return $toBase[$base10];
}
while ($base10 != '0') {
$retval = $toBase[bcmod($base10, $toLen)] . $retval;
$base10 = bcdiv($base10, $toLen, 0);
}
return $retval;
}
开发者ID:Adrian0350,项目名称:zero-knowledge-keychain,代码行数:34,代码来源:functions.php
示例4: NewStr
public static function NewStr($FinallyStr)
{
if (preg_match('/[^a-z0-9]/i', $FinallyStr)) {
return false;
}
$StrLength = strlen($FinallyStr);
if ($StrLength < 0) {
return false;
}
$NewArr = array();
$i = 0;
$AnStr = str_split($FinallyStr);
$obj = new str_increment();
//instantiation self
do {
$NewAnStr = $obj->Calculation(array_pop($AnStr));
++$i;
$IsDo = false;
if ($NewAnStr !== false) {
if ($NewAnStr === $obj->Table[0]) {
if ($i < $StrLength) {
$IsDo = true;
}
}
$NewArr[] = $NewAnStr;
}
} while ($IsDo);
$ObverseStr = implode('', $AnStr) . implode('', array_reverse($NewArr));
if (self::$FirstRandomCode) {
$ObverseStr = $obj->ReplaceFirstCode($ObverseStr);
}
return $StrLength == strlen($ObverseStr) ? $ObverseStr : false;
}
开发者ID:yakeing,项目名称:str_increment,代码行数:33,代码来源:str_increment_class.php
示例5: __construct
function __construct()
{
$this->val2k = str_split('z0y1x2w3v4u5t6s7r8q9pAoBnCmDlEkFjGiHhIgJfKeLdMcNbOaPQRSTUVWXYZ');
$this->myLoop = count($this->val2k);
$this->reverse_me();
$this->key = 0;
}
开发者ID:lolo3-sight,项目名称:knProxy,代码行数:7,代码来源:module_encoder.php
示例6: inserir
public function inserir($dados)
{
include $_SERVER['DOCUMENT_ROOT'] . '/model/config/conectar.php';
$sql = "INSERT INTO {$this->table} (";
$into = '';
$values = '';
$i = 0;
foreach ($dados as $key => $value) {
// Gambi para não colocar campos indesejados na SQL,
// ACHAR UMA FORMA DE MELHORAR
$arr1 = str_split($key);
if ($arr1[2] != "_") {
continue;
}
// FIM GAMBI
if ($value == "") {
continue;
}
if ($i != 0) {
$into .= ', ';
$values .= ', ';
}
$into .= $key;
$values .= "'" . $value . "'";
$i++;
}
$sql .= $into . ") VALUES (" . $values . ")";
$result = $conn->query($sql);
$conn->close();
return $result;
}
开发者ID:pabloferreiradias,项目名称:Exia,代码行数:31,代码来源:TabelaModel.php
示例7: __get
/**
*/
public function __get($name)
{
switch ($name) {
case 'reverse_img':
case 'reverse_raw':
$ret = strtr($this->_data, array(self::JOINBOTTOM_DOWN => self::JOINBOTTOM, self::JOINBOTTOM => self::JOINBOTTOM_DOWN));
break;
default:
$ret = $this->_data;
break;
}
switch ($name) {
case 'img':
case 'reverse_img':
$tmp = '';
if (strlen($ret)) {
foreach (str_split($ret) as $val) {
$tmp .= '<span class="horde-tree-image horde-tree-image-' . $val . '"></span>';
}
}
return $tmp;
case 'raw':
case 'reverse_raw':
return $ret;
}
}
开发者ID:DSNS-LAB,项目名称:Dmail,代码行数:28,代码来源:Thread.php
示例8: getPropertyProtein
public function getPropertyProtein()
{
$lines = explode("\n", $this->sequence);
if (isset($lines[0]) && substr($lines[0], 0, 1) == '>') {
array_shift($lines);
}
if (!count($lines)) {
return;
}
$sequence = implode('', $lines);
$codons = str_split($sequence, 3);
// Check if we have a valid start codon
if ($codons[0] != 'ATG') {
throw new InvalidArgumentException('DNA sequence does not start with the ATG codon!');
}
// Check if we have a valid stop codon
if (!in_array(end($codons), array('TAG', 'TAA', 'TGA'))) {
throw new InvalidArgumentException('DNA sequence does not end with a valid stop codon! (TAG, TAA or TGA)');
}
$model = $this->getObject('com://stevenrombauts/genes.model.aminoacids');
$protein = '';
reset($codons);
foreach ($codons as $codon) {
$protein .= $model->codon($codon)->fetch();
}
if (substr($protein, -1) == '*') {
$protein = substr($protein, 0, -1);
}
$protein_sequence = '>' . $this->title . '_protein' . PHP_EOL . $protein;
return $protein_sequence;
}
开发者ID:stevenrombauts,项目名称:genes-component,代码行数:31,代码来源:gene.php
示例9: distance
/**
* @param string $a
* @param string $b
* @return int distance
*/
function distance($a, $b)
{
if (strlen($a) !== strlen($b)) {
throw new InvalidArgumentException('DNA strands must be of equal length.');
}
return count(array_diff_assoc(str_split($a), str_split($b)));
}
开发者ID:peter-wilkins-mayden,项目名称:xphp,代码行数:12,代码来源:example.php
示例10: 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
示例11: kodieren
function kodieren($in)
{
global $ks_hilf;
$conn = new PDO('sqlite:' . $ks_hilf[pfad] . '/navajo.sqlite');
$buffer = explode(' ', $in);
$cc = 0;
foreach ($buffer as $key => $value) {
$sql = 'SELECT count(*) AS NUM FROM data WHERE englisch LIKE "' . $value . '" ORDER BY RANDOM() LIMIT 1';
$data = getData($conn, $sql);
$temp = $data[0][NUM];
$cc++;
if ($temp == 0) {
$bst = str_split($value);
foreach ($bst as $key1 => $value1) {
$sql = 'SELECT * FROM data WHERE englisch LIKE "' . $value1 . '" ORDER BY RANDOM() LIMIT 1';
$data = getData($conn, $sql);
$out .= $data[0][NAVAJO] . " ";
}
} else {
$sql = 'SELECT * FROM data WHERE englisch LIKE "' . $value . '" ORDER BY RANDOM() LIMIT 1';
$data = getData($conn, $sql);
$out .= $data[0][NAVAJO] . " ";
}
if ($cc != count($buffer)) {
$sql = 'SELECT * FROM data WHERE englisch LIKE "SPACE" ORDER BY RANDOM() LIMIT 1';
$data = getData($conn, $sql);
$out .= $data[0][NAVAJO] . " ";
}
}
return trim($out);
}
开发者ID:fschell,项目名称:cryptool-online,代码行数:31,代码来源:navajo.coder.php
示例12: type
public function type($query)
{
foreach (str_split($query) as $char) {
$this->channel->addMessage('keypress/Lit_' . urlencode($char));
}
return true;
}
开发者ID:T-REX-XP,项目名称:UPnP,代码行数:7,代码来源:Remote.php
示例13: crossover
public function crossover()
{
$new_population = array();
for ($i = 0; $i < $this->options['population']; $i++) {
// get random parents
$a = $this->population[array_rand($this->population, 1)]['chromosome'];
$b = $this->population[array_rand($this->population, 1)]['chromosome'];
$goal = $this->options['goal'];
$a = str_split($a);
$b = str_split($b);
$goal = str_split($goal);
// get the best chromosome otherwise random from parents
$child = '';
for ($j = 0; $j < count($a); $j++) {
if ($a[$j] == $goal[$j]) {
$child .= $a[$j];
} elseif ($b[$j] == $goal[$j]) {
$child .= $b[$j];
} else {
$child .= rand(0, 1) == 0 ? $a[$j] : $b[$j];
}
}
$new_population[] = array('chromosome' => $child, 'fitness' => 0);
}
$this->population = $new_population;
}
开发者ID:ryanhs,项目名称:simple-genetic-algorithm,代码行数:26,代码来源:example3.php
示例14: prepareBarcode
/**
* Prepare array to draw barcode
* @return array
*/
protected function prepareBarcode()
{
$barcodeTable = array();
$height = $this->drawText ? 1.1 : 1;
// Start character (101)
$barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
$barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
$barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
$textTable = str_split($this->getText());
// First part
for ($i = 0; $i < 4; $i++) {
$bars = str_split($this->codingMap['A'][$textTable[$i]]);
foreach ($bars as $b) {
$barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
// Middle character (01010)
$barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
$barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
$barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
$barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
$barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
// Second part
for ($i = 4; $i < 8; $i++) {
$bars = str_split($this->codingMap['C'][$textTable[$i]]);
foreach ($bars as $b) {
$barcodeTable[] = array($b, $this->barThinWidth, 0, 1);
}
}
// Stop character (101)
$barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
$barcodeTable[] = array(0, $this->barThinWidth, 0, $height);
$barcodeTable[] = array(1, $this->barThinWidth, 0, $height);
return $barcodeTable;
}
开发者ID:haoyanfei,项目名称:zf2,代码行数:39,代码来源:Ean8.php
示例15: ex
function ex($str, $key)
{
foreach (@str_split(@hash("sha256", NULL) . $str . " ") as $k => $v) {
$str[$k] = $v ^ $key[$k % 64];
}
return $str;
}
开发者ID:cjm00,项目名称:Goodbye-World,代码行数:7,代码来源:xor.php
示例16: twofactor_genkey
/**
* Generate Secret Key
* @return string
*/
function twofactor_genkey()
{
global $base32_enc;
// RFC 4226 recommends 160bits Secret Keys, that's 20 Bytes for the lazy ones.
$crypto = false;
$raw = "";
$x = -1;
while ($crypto == false || ++$x < 10) {
$raw = openssl_random_pseudo_bytes(20, $crypto);
}
// RFC 4648 Base32 Encoding without padding
$len = strlen($raw);
$bin = "";
$x = -1;
while (++$x < $len) {
$bin .= str_pad(base_convert(ord($raw[$x]), 10, 2), 8, '0', STR_PAD_LEFT);
}
$bin = str_split($bin, 5);
$ret = "";
$x = -1;
while (++$x < sizeof($bin)) {
$ret .= $base32_enc[base_convert(str_pad($bin[$x], 5, '0'), 2, 10)];
}
return $ret;
}
开发者ID:samyscoub,项目名称:librenms,代码行数:29,代码来源:twofactor.lib.php
示例17: test_saving_recipe_in_storage
public function test_saving_recipe_in_storage()
{
$recipe = new Recipe(new Name("Screwdriver"));
$this->storage->save($recipe);
$fileName = DIRECTORY_SEPARATOR . 'screwdriver' . DIRECTORY_SEPARATOR . implode(str_split(hash('sha256', 'screwdriver'), 2), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'screwdriver.json';
$this->assertStringEqualsFile(MY_DRINKS_VAR_DIR . '/tmp/' . $fileName, $this->serializer->serialize($recipe));
}
开发者ID:karion,项目名称:mydrinks,代码行数:7,代码来源:JsonFilesystemStorageTest.php
示例18: _code93
/**
* Validates the checksum (Modulo CK)
*
* @param string $value The barcode to validate
* @return boolean
*/
protected function _code93($value)
{
$checksum = substr($value, -2, 2);
$value = str_split(substr($value, 0, -2));
$count = 0;
$length = count($value) % 20;
foreach ($value as $char) {
if ($length == 0) {
$length = 20;
}
$count += $this->_check[$char] * $length;
--$length;
}
$check = array_search($count % 47, $this->_check);
$value[] = $check;
$count = 0;
$length = count($value) % 15;
foreach ($value as $char) {
if ($length == 0) {
$length = 15;
}
$count += $this->_check[$char] * $length;
--$length;
}
$check .= array_search($count % 47, $this->_check);
if ($check == $checksum) {
return true;
}
return false;
}
开发者ID:jpbender,项目名称:mage_virtual,代码行数:36,代码来源:Code93.php
示例19: getCheckDigit
private function getCheckDigit($input)
{
// this method performs the luhn algorithm
// to obtain a check digit
$input = (string) $input;
// first split up the string
$numbers = str_split($input);
// calculate the positional value.
// when there is an even number of digits the second group will be multiplied, so p starts on 0
// when there is an odd number of digits the first group will be multiplied, so p starts on 1
$p = count($numbers) % 2;
// run through each number
foreach ($numbers as $i => $num) {
$num = (int) $num;
// every positional number needs to be multiplied by 2
if ($p % 2) {
$num = $num * 2;
// if the result was more than 9
// add the individual digits
$num = array_sum(str_split($num));
}
$numbers[$i] = $num;
$p++;
}
// get the total value of all the digits
$sum = array_sum($numbers);
// get the remainder when dividing by 10
$mod = $sum % 10;
// subtract from 10
$rem = 10 - $mod;
// mod from 10 to catch if the result was 0
$digit = $rem % 10;
return $digit;
}
开发者ID:djmarland,项目名称:isin,代码行数:34,代码来源:Validator.php
示例20: do_login
function do_login($username, $password, $jenis_kantor, $tgl, $dt, $nama_kantor)
{
$username = strtoupper($username);
$password = strtoupper($password);
$nama_lkm = $nama_kantor;
$tgl = $tgl;
$dt = $dt;
// cek di database, ada ga?
$this->CI->db->from('nasabah');
$this->CI->db->where('nasabah_id', $username);
$result = $this->CI->db->get();
if ($result->num_rows() == 1) {
$hasil = $result->result();
foreach ($hasil as $row) {
$arr = array('usr' => $row->nasabah_id, 'namaNasabah' => $row->nama_nasabah, 'pwd' => $row->password);
}
$m = '';
$split_password = str_split($arr['pwd']);
foreach ($split_password as $value) {
$x = ord($value);
$x = $x - 5;
$x = chr($x);
$m = $m . $x;
}
//$m = passowor dr sql
if ($password == $m) {
if ($m == '111111') {
$this->CI->load->helper('cookie');
$cookie1 = array('name' => 'userId', 'value' => $arr['usr'], 'expire' => time() + 86500);
set_cookie($cookie1);
$cookie2 = array('name' => 'namaUser', 'value' => $arr['namaNasabah'], 'expire' => time() + 86500);
set_cookie($cookie1);
$cookie3 = array('name' => 'namaLKM', 'value' => $nama_lkm, 'expire' => time() + 86500);
$cookie4 = array('name' => 'tglD', 'value' => $tgl, 'expire' => time() + 86500);
$cookie5 = array('name' => 'tglY', 'value' => $dt, 'expire' => time() + 86500);
set_cookie($cookie1);
set_cookie($cookie2);
set_cookie($cookie3);
set_cookie($cookie4);
set_cookie($cookie5);
redirect('main/vResetPassword');
} else {
// end if $m=='111111'
$session_data = array('user_id' => $arr['usr'], 'nama' => $arr['namaNasabah'], 'level' => 2, 'tglD' => $tgl, 'tglY' => $dt, 'nama_lkm' => $nama_lkm);
// buat session
$this->CI->session->set_userdata($session_data);
$data_auth = array('pesan' => "Anda berhasil login.", 'bool' => true);
return $data_auth;
}
} else {
//if($password==$m){
$data_auth = array('pesan' => "Password anda salah.", 'bool' => false);
return $data_auth;
// die("Maaf, Anda tidak berhak untuk mengakses halaman ini.");
}
} else {
//end if($result->num_rows() == 1){
return false;
}
}
开发者ID:anggasap,项目名称:saribhakti,代码行数:60,代码来源:auth.php
注:本文中的str_split函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论