Array question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kingdbag
Forum Newbie
Posts: 22
Joined: Wed Jul 12, 2006 6:22 pm

Array question

Post 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....
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

kingdbag
Forum Newbie
Posts: 22
Joined: Wed Jul 12, 2006 6:22 pm

Post 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?
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post 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:
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Array question

Post 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?
kingdbag
Forum Newbie
Posts: 22
Joined: Wed Jul 12, 2006 6:22 pm

Post 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]
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Code: Select all

$array = range('A', 'Z');
kingdbag
Forum Newbie
Posts: 22
Joined: Wed Jul 12, 2006 6:22 pm

Post by kingdbag »

Awesome, thanks!

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