PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 28th, 2004, 03:21 PM
p_admin p_admin is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 2 p_admin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
reading a text file with variables into php variables

I have a text file that has a series of variables in it, in the form

var1 = val1
var2 = val2
...

I am new to php and would like to read this file and parse it. The result being having the variables to use as global php variables.

The text file will have the parameters to control how the php displays information on the screen.

Reply With Quote
  #2  
Old October 28th, 2004, 03:24 PM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: Canada
Posts: 331 Viper_SB User rank is Private First Class (20 - 50 Reputation Level)Viper_SB User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 h 53 m 7 sec
Reputation Power: 5
read it using file() and then parse it with a regex to get the var and value out, then use extract() to put them all into php (or eval) as valid variables

Reply With Quote
  #3  
Old October 28th, 2004, 03:27 PM
p_admin p_admin is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 2 p_admin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by Viper_SB
read it using file() and then parse it with a regex to get the var and value out, then use extract() to put them all into php (or eval) as valid variables



could you point me to an example? I am not sure how to use regex() or extract()

thanks

Reply With Quote
  #4  
Old October 28th, 2004, 10:48 PM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: Canada
Posts: 331 Viper_SB User rank is Private First Class (20 - 50 Reputation Level)Viper_SB User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 h 53 m 7 sec
Reputation Power: 5
did you read the manual on those 2 functions? preg_match extract

I can help you with the regex but show me what you got, extract should be easy enough to figure out.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > reading a text file with variables into php variables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT