Welkom op Scriptkiddies!
Disclaimer - FAQ - Contact - About - Adverteren
  Home   Artikelen   Forum   Topic openen   Chat   Gastenboek   Links   Aanmelden

  CSS   JavaScript   ASP   PHP   Perl


  Virtuax  MSN Stuff  WebSonic  Avondzon.nl  habbo-dj-music  scripttrip  Tuts.nl | Tutorial CMeer linkpartners

Random string functie
Auteur: MijnNaam (lid)
Gepost: 22:09:39 13-07-2004
Stuur prive bericht
Het maakt een random string aan, met de gegevens die jij opgeeft. Let op dat je niet voor alle drie de parameters false opgeeft, want dan krijg je een foutmelding.

Meer uitleg: Zie script. Een heel blok. :D
<?php
/*
***************************************************************************
* Function random_string(), used to generate a random string of the       *
* characters you specify, with a length of your choice.                   *
* Copyright (C) 2004 The Celestial Celebi                                 *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the   *
* Free Software Foundation; either version 2 of the License, or (at your  *
* option) any later version.                                              *
* This program is distributed in the hope that it will be useful, but     *
* WITHOUT ANY WARRANTY; without even the implied warranty of              *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
* General Public License for more details.                                *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.               *
***************************************************************************
*/

/*
***************************************************************************
* @function: random_string(): Returns a random string, created from the   *
*  characters you specify.                                                *
* @param $iLength (int): The length of the random string.                 *
* @param $bUseLowercase (bool): Use lowercase characters in the string?   *
* @param $bUseUppercase (bool): Use uppercase characters in the string?   *
* @param $bUseNumbers (bool): Use numbers in the string?                  *
* @return string: The random string of $iLength characters.               *
*-------------------------------------------------------------------------*
* @started on: 23 June 2004 at 20:00:00 by The Celestial Celebi.          *
* @last edited on: 23 June 2004 at 20:01:43 by The Celestial Celebi.      *
* @constructs used: array, if, for, return.                               *
* @functions used: array_merge, count, rand, range.                       *
***************************************************************************
*/

function random_string($iLength$bUseLowercase$bUseUppercase$bUseNumbers)
{
    
$aCharactersToChoose = array();
    if(
$bUseLowercase)
    {
        
$aCharactersToChoose array_merge($aCharactersToChooserange('a''z'));
    }
    if(
$bUseUppercase)
    {
        
$aCharactersToChoose array_merge($aCharactersToChooserange('A''Z'));
    }
    if(
$bUsenumbers)
    {
        
$aCharactersToChoose array_merge($aCharactersToChooserange(09));
    }
    
$iNumCharacters = (count($aCharactersToChoose) - 1);
    
$sRandomString '';
    for(
$i 0$i <= $iLength$i++)
    {
        
$sRandomString .= $aCharactersToChoose[rand(0$iNumCharacters)];
    }
    return 
$sRandomString;
}
?>
download het script    




Reacties van leden

Auteur: DaddyDJ @ 08-10-2004

Kan ook anders:

<?php
function random_string()
{
$aArguments = func_get_args();

if(count($aArguments) == 1)
{
return func_get_arg(0);
}
elseif(empty($aArguments))
{
trigger_error("Wrong parameter count for random_string()..",E_USER_WARNING);
}
else
{
return $aArguments[rand(0,count($aArguments)];
}
}
echo random_string("a","b","c");
?>




Gebruikersnaam:
Wachtwoord:

Brochures.nl  gratis criminals...  forum probleem  sql file nodig!  wild west game  script gezocht  wat te denken ove...  rabo internetbank...  oehoe!  site tekoop  koppeling zoek &...

Scriptkiddies telt momenteel 6407 leden, er zijn 359 scripts en er zijn momenteel 9 mensen online waarvan 0 leden.

Hoeveel sites heb jij?
Geen
1
2
5
meer dan 5

Parkeren Schiphol Profielen tip NatuurRampen tip JS-Systems LoveBoyz Ringtones! Woning aanbod Weblog maken
Copyright by Jacob Slomp