?
Solved

How to change two parameters in a PHP file?!

Posted on 2008-06-12
4
Medium Priority
?
240 Views
Last Modified: 2008-06-19
Hello group,

I'm writing a small web application which allows a user to upload a game (Flash base). Let's say user uploads a file called game.swf
On the fly, the code creates a game.php associated to the game. So now we have:
1) game.swf
2) game.php files on server.

The generated PHP file is a page and it also has the <embed> tag injected in it. Of course, it has two parameters as WIDTH and HEIGHT which specify the dimension of the game. So far, I don't have any issue.

The problem is that if the game owner decides to apply changes (such as name, description and etc) it works fine but I don't know how to change the width and height parameters which already are hard coded in the generated PHP file.

Is there any function that let me to change two or more values in an existing PHP/HTML file?

Any suggestions or advice will be appreciated.

Regards.
0
Comment
Question by:akohan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Assisted Solution

by:afzz
afzz earned 400 total points
ID: 21772683
If the file is not too big use the file() function to read the file into an array, loop through the array to find what you want to change while saving the rest into another variable when you come acroos the values to change, save the changed values into the new variable and finally write it back to the file

0
 

Author Comment

by:akohan
ID: 21772751

Yes, it is small. I will give a try.

Thanks!
0
 
LVL 5

Accepted Solution

by:
pbeirne earned 1600 total points
ID: 21772772
You could keep the width and height parameters in an include file or stored in a mySQL database rather than hard coding them in your page.  Then your application's update routine could update or replace the include file or mySQL and your PHP page wouldn't have to be modified.
0
 

Author Comment

by:akohan
ID: 21825693

Both methods were fine but the latter gave me more flexiblity.

Thanks to all.
Regards.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question