note 115601 added to control-structures.for
| From: | Anonymous | Date: | Sat, 23 Aug 2014 11:39:54 +0000 |
| Subject: | note 115601 added to control-structures.for | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-200292@lists.php.net to get a copy of this message | ||
You can also work with arrays. For example, say you want to generate an array of 12 unique 2-letter
strings:
<?php
for ($names = array(); count($names) < 12; $names = array_unique($names)) {
/**
* we assume here we have some $faker object
* which generates n-letter strings
*/
$names[] = $faker->word(2);
}
print_r($names);
?>
will print something like:
Array
(
[0] => cc
[1] => cb
[2] => dd
[3] => db
[4] => bb
[6] => cd
[8] => aa
[9] => ad
[10] => ca
[11] => ac
[12] => dc
[15] => ab
)
----
Server IP: 46.17.113.50
Probable Submitter: 88.156.230.184
----
Manual Page -- http://php.net/manual/en/control-structures.for.php
Edit -- https://master.php.net/note/edit/115601
Del: integrated -- https://master.php.net/note/delete/115601/integrated
Del: useless -- https://master.php.net/note/delete/115601/useless
Del: bad code -- https://master.php.net/note/delete/115601/bad+code
Del: spam -- https://master.php.net/note/delete/115601/spam
Del: non-english -- https://master.php.net/note/delete/115601/non-english
Del: in docs -- https://master.php.net/note/delete/115601/in+docs
Del: other reasons-- https://master.php.net/note/delete/115601
Reject -- https://master.php.net/note/reject/115601
Search -- https://master.php.net/manage/user-notes.php