Okay, so i'm very new to PHP... here is what i'm trying to do, if possible. I want to be able to take a variable obtained by html user input and have PHP write that variable to a js file.

Here is part of the code in the js file:
function init1()
fx: 'fade',
timeout: 15000,
fit: 1

I want to be able to have PHP open this file search for "fx:" and change " 'fade', "
So something similar to this:


$data = file_get_contents('file.js');

if(strpos($data, 'fx:') !== FALSE)
// found 'fx:'
// Did not find 'fx:'


Am I on the right path here? is it possible to do this with a .js file or does it have to be .txt? also if I did it this way how could I change 'fade' rather than chaning "fx:"?
Let me know if I didn't explain this well enough, and thanks for any tips or advice!