For integration with scripts made with PHP & Perl, too numerous to mention, I need to output some rather large strings of text (up to about 500 words) into a text file in this format:
data.test_case="This is the string. It can be really really long. Sometimes it can reach the 500 word mark. Boy is that long. You know what, that is really long. So ong I don't know what to write anymore. Hence I will stop here.";
data.something_else=Yes
data.another_thing=no
Notice large strings are in "" and yes/no are not.
I've been using this homemade junk to read text from the files up until now:
function readconfig($config){
$filename = "$this->configfile";
$fp = fopen($filename, "r");
$configdat = fread($fp, filesize($filename));
fclose($fp);
$configlines = explode("\n", $configdat);
$i = 0;
while ($i <= sizeof($configlines)) {
$configLn = explode("=", $configlines[$i]);
preg_match ("/$config/i", "$configLn[0]", $result);
if (($result[0]) && (strlen($config) == strlen($configLn[0]))){
break;
}
$i++;
}
$value = substr($configLn[1], 0, strlen($configLn[1])-1);
if (strchr(substr($value, 0, 1), "\"")){
$value = substr($value, 1, strlen($value)-2);
}
return $value;
The problem is if there is a return in the string, causes everything to get messed up. So I guess I have to teach it to read from quote to quote "..........";
the problem there, is, what if there is a quote in the text?
So can anyone provide a solution for this? I can't believe I am the first to encounter this issue.