nst
05-13-2007, 12:46 PM
Assuming I have the following line from a text file
define ('THIS_IS_A_TITLE', 'My data for this title');
which I load into a variable, therefore
$line = define ('THIS_IS_A_TITLE', 'My data for this title')
My purpose is to get two variables from that like
$title = THIS_IS_A_TITLE
$data = My data for this title
How would you do that? I thought of counting the ' characters, then $title begins after the 1st ' and ends before the 2nd, whilst $data begins after the 3rd ' and ends before the 4th.
But maybe there is a more elegant way. Any ideas?
Thanks.
P.S There are of course more $title and $data, $line would be a part of an array of lines from a text file, that is why I say an iterative method.
define ('THIS_IS_A_TITLE', 'My data for this title');
which I load into a variable, therefore
$line = define ('THIS_IS_A_TITLE', 'My data for this title')
My purpose is to get two variables from that like
$title = THIS_IS_A_TITLE
$data = My data for this title
How would you do that? I thought of counting the ' characters, then $title begins after the 1st ' and ends before the 2nd, whilst $data begins after the 3rd ' and ends before the 4th.
But maybe there is a more elegant way. Any ideas?
Thanks.
P.S There are of course more $title and $data, $line would be a part of an array of lines from a text file, that is why I say an iterative method.