[eluser]ProImage Web[/eluser]
I'm trying to read a file and extract a string between two other strings multiple times.. I can read the file, and extract the first string without incident, however, i'm having trouble with the loop..
The idea is to enter a start and stop string, then parse the file extracting the desired string from between the start and stop multiple times and write the results to another file. Any help would be appreciated,
here's the code i have so far.
Code:
$filename = $this->upload->file_name;
$file_path = './uploads/';
$write_path ='./uploads/data.php';
$orig_name = $this->upload->orig_name;
$start_string = $this->input->post('start_string');
$stop_string = $this->input->post('stop_string');
$data = read_file($file_path.$filename);
$deduct = strlen($start_string); // needed for substr to remove the start_string from the result
$between = substr(substr($data, strpos($data, $start_string), strpos($data, $stop_string) - strpos($data, $start_string)), $deduct);
echo $between;
What i'd like to happen is this:
explode the file into an array then perform a foreach loop on the array pieces, and return the $between[$i] values, so that they can be imploded back into an array and written to a file..
I can picture it in my head and i've exhausted every attempt, perhaps a fresh perspective could get me in the right direction... oh and btw, i've only been Ignited for 4 months, cut me some slack