Page 1 of 1

Array question

Posted: Thu Feb 15, 2007 12:18 pm
by kingdbag
I'm trying to make a password gen script for personal use and I'm just wondering about a clean way of using an array.

abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1234567890
!@#$%^&*()_+-=[]{};':",./?

Do i pretty much have to store all this in an array the generic way ($COLORS= array('zero', 'one', 'two', 'three') or can I use regular expressions [a-z] but then how would that work calling array ID's etc....

Posted: Thu Feb 15, 2007 12:22 pm
by Oren

Posted: Thu Feb 15, 2007 12:28 pm
by kingdbag
Well, I didn't need the entire code.... It was kinda something i ran into making the passgen and was wondering if there is anything cool you can do with arrays besides the 2 or 3 generic ways to add to the array. Or is it easier to use a string like this example and just pull things from it?

Posted: Thu Feb 15, 2007 12:34 pm
by Oren
Well I guess it depends if you want a strong password (e.g a password with digits, characters, lowercase and uppercase letters) or not... I believe that you can find much more information in the Google search than I could give you :wink:

Re: Array question

Posted: Thu Feb 15, 2007 1:50 pm
by RobertGonzalez
kingdbag wrote:Do i pretty much have to store all this in an array the generic way ($COLORS= array('zero', 'one', 'two', 'three') or can I use regular expressions [a-z] but then how would that work calling array ID's etc....
Can you clarify this question? What other way is there to store data in an array?

Posted: Thu Feb 15, 2007 6:13 pm
by kingdbag
Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Well the 2 most common I would think are these (or other with similar formatting):

Code: Select all

$Array = array();

$Array[]="http://www.yahoo.com/";
$Array[]="http://www.internet.com";
$Array[]="http://www.google.com";
$Array[]="http://www.cnn.com/";
$Array[]="http://www.php.net/";
or this

Code: Select all

$Array=array("http://www.yahoo.com", "http://www.internet.com", "http://www.google.com", "http://www.cnn.com/","http://www.php.net/");
I guess what im trying to say is if I have an array with something in common like A-Z do I really have to do

Code: Select all

$Array=array(A,B,C,D,etc)
or can I do something like

Code: Select all

$Array=array([A-Z]);
I tried finding info on it and I kept coming up with the generic ones....


Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Feb 15, 2007 6:50 pm
by RobertGonzalez

Code: Select all

$array = range('A', 'Z');

Posted: Fri Feb 16, 2007 10:15 am
by kingdbag
Awesome, thanks!

Sorry about the code i'll use the tags from now on.