Dynamic varialbes from text file - PHP
Filed in PHP on Oct.05, 2007
This code snippet demonstrates how to read a resource file and convert them to php variables:
< ?_php
$arr = file("resource.txt");
foreach ($arr as $key => $value) {
$arr = split(”t”,$value); // tab delimeted. You can use any.
$$arr[0] = $arr[1];
}
//Example - “name” is a word in text tile with ‘tab’ delimeted sample text.
echo $name;
?>
Sample resource.txt file: (tab delimeted)
txt_title hello world
txt_message this is a message
name Contact
Related posts:






















