![]() |
|
|||||||
| Notices |
| Programming Forum Web and Software Programming Forum - Java, PHP, SQL etc. |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
How can you fill an array with info from an include? I've basically got:
Code:
$names = array( include("names.txt"));
...
Hope that made sense. Harry
__________________
Standards Compliant Web Consulting and Development | Labs - Free Snippets and Codes | CSS Wizardry |
|
||||
|
doing it wrong hence its not working
PHP Code:
try the above. *havn't coded in php for a while (asp .net geek) so hope it works. if not try PHP Code:
__________________
C# Developer, Passionate Nikon D80 Photographer, Motorcycle Lover BlooGrape.co.uk |
|
||||
|
@Andy, I know how to include files, but when I include it into an array it goes wrong. Here's what I'm working with:
the php: Code:
Code:
"David" => "danjz.sL9bgaQ", "Admin" => "daguOy8u.JOqY", Cheers.
__________________
Standards Compliant Web Consulting and Development | Labs - Free Snippets and Codes | CSS Wizardry |
|
||||
|
I have a headache so i'm not going to do much for you on this right now. But this should be enough to get you started in the right direction:
names.php = PHP Code:
PHP Code:
Your admin form should modify the names.php file to add a new line like i've written above for each new user. Simple enough script. Your names.php is then read in as an array already with the username as the key and the password as the corresponding value for each key. You've got the wrong idea of an include. Here's an example: Take the 2 files above (names.php and login.php). a (half) processed version of login.php looks like this right after the include is performed: PHP Code:
PHP Code:
)You get the picture.
__________________
Subtlety is my middle name... and first and last in case you didn't get the point. |
|
||||
|
Quote:
Cheers for the rest though!
__________________
Standards Compliant Web Consulting and Development | Labs - Free Snippets and Codes | CSS Wizardry |
|
||||
|
It works a dream if you input it directly into an array, but as for an include... i'm not so sure... but like i said, me = headache, so i can't think straight right now.
The way i wrote above is how i'd do it anyway. Easy to modify, easy to use.
__________________
Subtlety is my middle name... and first and last in case you didn't get the point. |
|
||||
|
Wicked, cheers! Thanks a lot. Get an asprin down you. Thanks again.
EDIT: Here you go mate: ![]()
__________________
Standards Compliant Web Consulting and Development | Labs - Free Snippets and Codes | CSS Wizardry Last edited by PR Design; 17-10-2007 at 09:20 PM. |
|
||||
|
Ok, I'm really sorry to keep bothering you about this, but I have one last question. All the stuff you told me works a treat :) Thank you! But, when I set up the form which appends names.php it will add the new credentials after the closing php tag won't it? Is it possible to append a certain point in a file, ie before the ?>?
Thanks for all your help with this! Harry
__________________
Standards Compliant Web Consulting and Development | Labs - Free Snippets and Codes | CSS Wizardry |
|
||||
|
Yes, you use file to load that php file into an array.
The first and last entries in the array are your php opening and closing tags so you ignore those and rewrite them at the end. PHP Code:
But try that out.
__________________
Subtlety is my middle name... and first and last in case you didn't get the point. |
![]() |
|
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| PHP Includes | Andy | Programming Forum | 3 | 25-01-2007 05:15 PM |
| All times are GMT. The time now is 07:38 AM. |