Lost Password?


Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-22-2006, 07:23 PM
Paradine Paradine is offline
Learning Programmer
 
Join Date: Oct 2006
Posts: 48
Rep Power: 8
Paradine is on a distinguished road
Default Variable Names

Hello,
If I have variable names in a text file how can I use those names as variables?

I have "cont" as a string in a file. That is read in using fopen. How can I use $cont as my variable?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 11-01-2006, 12:52 AM
John's Avatar   
John John is online now
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,433
Last Blog:
Google Web Toolkit
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

I believe when you use fopen, the entire content of the file is stored as a string. Therefor you would need to use some method to parse the content. Either using regex or some string functions such as sscanf.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-02-2006, 09:27 AM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,149
Rep Power: 18
Lop will become famous soon enoughLop will become famous soon enough
Default

So you want to turn a string into a variable? Why? You could always use an array to do this:

Code:
$myArray['cont']
so to apply you would use

Code:
$myArray[$str]->'value';
Where $str is the variable name from the text file.
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 11-03-2006, 12:29 PM
Paradine Paradine is offline
Learning Programmer
 
Join Date: Oct 2006
Posts: 48
Rep Power: 8
Paradine is on a distinguished road
Default

Yes, I need the variable name to be the array. I suppose I could use an array but it is just easier when going through the list again to say print $variable instead of finding the name and searching an array.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Solved] Long names for Category title and Name julial ionFiles 5 07-26-2007 09:58 AM
Using input to change a variable? Plutonic Java Help 3 07-17-2007 05:02 PM
Free Domain Names techni68 Hosting and Registrars 10 03-04-2007 10:12 AM
Java:Tutorial - The Variable John Java Tutorials 0 12-09-2006 10:59 AM
Variable to Debug Window Void C# Programming 3 07-04-2006 09:26 AM


All times are GMT -5. The time now is 05:10 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 98%

Ads