PHP to make vars and values part of array
- by Chris
I currently have this function to search and replace in a text file.
// Input
$ect = array('Visssa', 'Lisssa', 'her');
// Placeholders in the file
$put = array('lname', 'fname', 'hisher');
// Replace the placeholders
$oput = str_replace($put, $ct, 'tmpfile.txt');
This is not the full program but the idea is replace the values found in tmpfile.txt with the ones found in the $etc array. And it works flawlessly.
But, what I need to do is get all passed vars (get/post) and then make the arrays so that the var is the value to replace and the value is the value to replace it with.
So, if I sent the url http://xyz.com/?lname=tom&ogre=yes
All instances of lname in the file would be replaces with tom and all instances of ogre would be replaced with yes.
So somehow it just gets any/all variables passed in get/post and then the arrays showed above would cause the var to be replaced by the value in the file.