¡@

Home 

php Programming Glossary: rand

unserialize() [function.unserialize]: Error at offset

http://stackoverflow.com/questions/10152904/unserialize-function-unserialize-error-at-offset

' ^a z0 9 i' '' session_id key md5 microtime . sid . rand sql INSERT INTO . TABLE_TEMPDATA . tempdata_key tempdata_value..

Secure random number generation in PHP

http://stackoverflow.com/questions/1182584/secure-random-number-generation-in-php

random number generation in PHP Use case the I forgot my password.. in hashed form so the only thing to do is generate a new random password and e mail it to him. This requires cryptographically.. it to him. This requires cryptographically unpredictable random numbers for which mt_rand is not good enough and in general..

How to Use AJAX in a WordPress Shortcode?

http://stackoverflow.com/questions/13498959/how-to-use-ajax-in-a-wordpress-shortcode

AJAX in a WordPress Shortcode I have a code to display a random quote. One person wrote a function to implement all of this... file _POST 'file_path' file path in _POST as from the js r rand 0 count array 1 return ' p ' . array r . ' p ' The HTML Structure.. In a page content a widget or a template file div id randomquotes p I would rather have my ignorance than another man..

PHP: How to generate a random, unique, alphanumeric string?

http://stackoverflow.com/questions/1846202/php-how-to-generate-a-random-unique-alphanumeric-string

How to generate a random unique alphanumeric string How would it be possible to generate.. string How would it be possible to generate a random unique string using numbers and letters for use in a verify.. time in microseconds. I think I'll use that. php string random uniqueidentifier share improve this question If you do..

SHA1 vs md5 vs SHA256: which to use for a PHP login?

http://stackoverflow.com/questions/2235158/sha1-vs-md5-vs-sha256-which-to-use-for-a-php-login

as a hash in mysql function createSalt string md5 uniqid rand true return substr string 0 3 salt createSalt hash sha1 salt..

How is the PHP array implemented on the C level?

http://stackoverflow.com/questions/2350361/how-is-the-php-array-implemented-on-the-c-level

you'd think at first glance. Like in the case of array_rand on a very large array 10000 . array_rand is so slow in fact.. the case of array_rand on a very large array 10000 . array_rand is so slow in fact that in cases where your using the php array.. using the php array as an indexed array a function like rand 0 array_length array 1 runs MUCH faster than array_rand . Now..

List of Big-O for PHP functions

http://stackoverflow.com/questions/2473989/list-of-big-o-for-php-functions

that in mind. shuffle is on the same Big O tier as array_rand array_pop array_push is faster than array_shift array_unshift.. array_replace O array_i for all i Random shuffle O n array_rand O n Requires a linear poll. Obvious Big O array_fill O n array_fill_keys.. indexes test_indexes array for j 0 j tests j test_indexes rand 0 i 1 benchmark array lookups start microtime TRUE foreach..

Simple “Long Polling” example code?

http://stackoverflow.com/questions/333664/simple-long-polling-example-code

in the coming Javascript example msgsrv.php php if rand 1 3 1 Fake an error header HTTP 1.0 404 Not Found die Send a.. header HTTP 1.0 404 Not Found die Send a string after a random number of seconds 2 10 sleep rand 2 10 echo Hi Have a random.. Send a string after a random number of seconds 2 10 sleep rand 2 10 echo Hi Have a random number . rand 1 10 Note With a real..

Preserve key order (stable sort) when sorting with PHP's uasort

http://stackoverflow.com/questions/4353739/preserve-key-order-stable-sort-when-sorting-with-phps-uasort

'Content type text plain' for i 0 i 10 i arr 'key '. i rand 1 5 10 uasort arr function a b sort condition may go here Tried..

PHP random string generator

http://stackoverflow.com/questions/4356289/php-random-string-generator

random string generator I'm trying to create a randomized string.. random string generator I'm trying to create a randomized string in PHP and I get absolutely no output with this.. randstring '' for i 0 i 10 i randstring characters rand 0 strlen..

Who needs singletons? [closed]

http://stackoverflow.com/questions/4595964/who-needs-singletons

function __construct static function get if isset self rand self db new PDO 'mysql host 127.0.0.1 dbname toto' 'user' 'pwd'..

PhpUnit private method testing

http://stackoverflow.com/questions/5937845/phpunit-private-method-testing

function b return 5 this c private function c return mt_rand 1 3 i can see the need to want to mock out c since the random.. 1 3 i can see the need to want to mock out c since the random function is global state and you can't test that. The clean.. b return 5 this c private function c return this foo rand 1 3 now there is no more need to mock c out since it does not..

How to create a random string using PHP?

http://stackoverflow.com/questions/853813/how-to-create-a-random-string-using-php

to create a random string using PHP I know that the rand function in PHP generates.. to create a random string using PHP I know that the rand function in PHP generates random integers but what is the best.. using PHP I know that the rand function in PHP generates random integers but what is the best way to generate a random string..

Doing a while / loop to get 10 random results

http://stackoverflow.com/questions/9945691/doing-a-while-loop-to-get-10-random-results

a while loop to get 10 random results Hello i'm trying to make a tag script for my website.. do a while Like so sql SELECT tagname FROM tags ORDER BY rand LIMIT 10 result mysql_query sql row mysql_fetch_object result.. amount of data but it doesn't seem that it will order by rand can have a bad effect on the performance consider using pdo..

How to select randomly with doctrine

http://stackoverflow.com/questions/10762538/how-to-select-randomly-with-doctrine

similar question which basically suggests since ORDER BY RAND is not supported in doctrine you can randomize the primary key.. own drawbacks Add a custom numeric function see this DQL RAND function might be slow if you have lots of matching rows Use.. the first solution other raw SQL techniques than ORDER BY RAND exist I won't detail them here you'll find some good resources..

Random range without duplicates in PHP

http://stackoverflow.com/questions/16184116/random-range-without-duplicates-in-php

class allitems item' . i . ' a ' I found PHP function RAND but unable to implement any help would be appreciated. php..

MySQL: Select Random Entry, but Weight Towards Certain Entries

http://stackoverflow.com/questions/2417621/mysql-select-random-entry-but-weight-towards-certain-entries

been trying to figure out how to do this with SELECT and RAND but don't know how to do the weighting. Is it possible php.. in the comments someone suggests using ORDER BY LOG 1.0 RAND Multiplier which in my testing gave pretty much perfect results...

MySQL select random row with JOIN from two tables

http://stackoverflow.com/questions/4209886/mysql-select-random-row-with-join-from-two-tables

'Online' AND a.unique_id b.product_unique_id ORDER BY RAND LIMIT 1 This query takes around 2.3secs to run. This is quite.. random product_db.unique_id In your query replace ORDER BY RAND with AND product_db.unique_id ROUND RAND SELECT MAX unique_id.. replace ORDER BY RAND with AND product_db.unique_id ROUND RAND SELECT MAX unique_id FROM product_db using instead of in case..

magento get products from category, order by rand()

http://stackoverflow.com/questions/4356019/magento-get-products-from-category-order-by-rand

'catalog product' getCollection addAttributeToSort 'id' 'RAND ' addAttributeToSelect 'small_image' addCategoryFilter Mage.. 'catalog category' load catId But I need to order by id RAND how can I do this The code shows how I've tried with no luck.. category' load products getSelect order new Zend_Db_Expr 'RAND ' To see what query will be executed you may use this construnction..

Select variable number of random records from MySQL

http://stackoverflow.com/questions/558719/select-variable-number-of-random-records-from-mysql

strSQL SELECT id FROM site_info WHERE major 0 ORDER BY RAND LIMIT . intNumberofSites. Not wonderfully random strSQL SELECT.. id FROM site_info WHERE major 0 AND id SELECT FLOOR COUNT RAND FROM site_info ORDER BY id LIMIT . intNumberofSites. Manual.. return arrOutput UPDATE QUESTION I know about the ORDER BY RAND I just don't want to use it because there are rumors it isn't..

jQuery - Call ajax every 10 seconds

http://stackoverflow.com/questions/5687600/jquery-call-ajax-every-10-seconds

PHP file result mysql_query SELECT FROM feedback ORDER BY RAND LIMIT 0 1 while row mysql_fetch_array result name row 'name'..

Benchmarking Performance of node.js (cluster) with mysql pools : Lighttpd + PHP?

http://stackoverflow.com/questions/7658333/benchmarking-performance-of-node-js-cluster-with-mysql-pools-lighttpd-php

100 req sec. Edit 1 After someone suggesting that ORDER BY RAND would cause MySQL to be slow I had removed that clause from.. if conn result conn query 'SELECT FROM tb_users ORDER BY RAND ' if result echo result num_rows .' ROWS found using Lighttpd..

PHP MySQL Triggers - How to pass variables to trigger?

http://stackoverflow.com/questions/7750208/php-mysql-triggers-how-to-pass-variables-to-trigger

EACH ROW BEGIN DECLARE newsalt INTEGER SET newsalt FLOOR RAND 999999 INSERT INTO users username salt passhash VALUES NEW.username..

PDO utf-8 character issue

http://stackoverflow.com/questions/7822461/pdo-utf-8-character-issue

query SELECT FROM .ARTIST_TABLE. WHERE id 11 ORDER BY RAND LIMIT 1 artist setFetchMode PDO FETCH_OBJ artist artist fetch..

Doing a while / loop to get 10 random results

http://stackoverflow.com/questions/9945691/doing-a-while-loop-to-get-10-random-results

about iterating the result set not about the usage of the RAND function The query doesn't even appear in my answer and I am..