How to convert string to variable (string variable --> $variable)?
Or a list of variables delimited by commas then convert to actual variables.
I have 2 files:
- column names file
- rows file
I need to match a whole row from the rows file based on a string, and name each row based from the column names file.
Example:
COLUMN NAMES FILE content
name,age,gender
ROWS FILE content
mar,44,m
rich,49,m
glenn,22,m
Now I have a variable string $who = 'glenn'
I will first match it on the ROWS FILE.
Then I need to name its matched contents with an actual variable with its name based on the COLUMN NAMES FILE.
Output:
$name = 'glenn';
$age = 22;
$gender = 'm';
I need something that dynamically changes, creating the needed variables and contents automatically by only updating the content files.