Cik labs ir šis variants? function trueRandom()
{
global $db;
for ($check->num_rows === 0; $check = $db->query("select * from tweets where textid = '$randomIDz'"); $randomIDz = random_string(1, 6, '', 'lower_num'))
{
if ($check->num_rows === 0 && $randomIDz != '') // hardcore fix, lai pirmajā riņķī neatgrieztu tukšu vērtību
{
return $randomIDz;
}
}
}
random_string funkcija. Labu laiku atpakaļ rakstīta.
<?php
function random_string($blocks, $chars, $spacer, $charset)
{
$b = 0;
if ($charset == 'upper')
{
$symbols = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
}
else if ($charset == 'upper_num')
{
$symbols = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
}
else if ($charset == 'lower')
{
$symbols = 'abcdefghijklmnopqrstuvwxyz';
}
else if ($charset == 'lower_num')
{
$symbols = 'abcdefghijklmnopqrstuvwxyz0123456789';
}
else if ($charset == 'num')
{
$symbols = '0123456789';
}
else if ($charset == 'letters')
{
$symbols = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
}
else
{
$symbols = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
}
while ($blocks > $b)
{
$s = 0;
while ($chars > $s)
{
$char = substr(str_shuffle($symbols), 0, 1);
if ($s == $chars - 1 && $b != $blocks - 1)
{
$char = $char . $spacer;
}
$output = $output . $char;
$s = $s+1;
}
$output2 = $output;
$b = $b+1;
}
return $output2;
}
SJohnson miniblogs
- 0
SJohnson 19.12.2013. 06:06
Ielogojies vai izveido profilu, lai komentētu!