Solved

How to change two parameters in a PHP file?!

Posted on 2008-06-12
4
194 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
  • 2
4 Comments
 
LVL 4

Assisted Solution

by:afzz
afzz earned 100 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 400 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now