Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > can i read array contents from file?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-04-04, 23:45
rei rei is offline
Registered User
 
Join Date: Jul 2004
Posts: 30
can i read array contents from file?

i'm doing something like the following
Code:
$dictionary=array( 1=>"word1", 2=>"word2", 3=>"word3", 4=>"word4", 5=>"word5", 6=>"word6");

I might change the contents anytime, inserting a word between 1 & 2, or moving word3 to be displayed after word5 etc..

it's very troublesome to change a code everytime,
so is there anyway that i can read from a conf file, and insert everyline from conf file to the array?

i only have to write:
word1
word2
word3
word4
word5
word6
in my conf file, and it will be inserted into my array according to the sequences in the conf file.

thanks
Reply With Quote
  #2 (permalink)  
Old 10-05-04, 11:40
rajesh_r_r rajesh_r_r is offline
Registered User
 
Join Date: Jan 2004
Location: India
Posts: 168
You question is not that clear..but still based ona guess like
if you want to insert some values into an array based ona sequesnce from a conf file you have to check the order in the conf file first and the use array_push() function to insert the value.

Regards
Rajesh
__________________
Freelance and Technology Consultant
-------------------
Dreams are for ever
-------------------
Reply With Quote
  #3 (permalink)  
Old 10-05-04, 12:56
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 525
I don't have a ready example to show you, but what you'll need to do is read in the file, Use the Explode Function to convert the text to an array.
$array = explode("\n", $string); arguments are 'delimiter' and 'string to explode'
use array_push to add variables to the array.
use the implode function to rejoin the array.
write the array back to the file.

This may help
Unset Function
http://www.php.net/manual/en/function.unset.php

Array Functions
http://www.php.net/manual/en/ref.array.php

'
__________________
~

Bill

Last edited by savbill : 10-05-04 at 13:01.
Reply With Quote
  #4 (permalink)  
Old 10-12-04, 06:22
rei rei is offline
Registered User
 
Join Date: Jul 2004
Posts: 30
thanks rajest & savbill,

i've found out another way to do it, that's with eval()
experimenting everything now
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On