PHP to make vars and values part of array

Posted by Chris on Stack Overflow See other posts from Stack Overflow or by Chris
Published on 2012-10-26T04:36:28Z Indexed on 2012/10/26 5:01 UTC
Read the original article Hit count: 137

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays