I'm looping through a file, parsing each line of text. I have a global array that i
append each line to. When my criteria is met. I mark that line. This line will
begin an array that I will later write out. After writing out the array I zap it and
reuse it for the next time my criteria is met. The problem I'm having is the first
time my criteria is met, I don't want to write out the array, only the subsequent
times my criteria is met; do I want to write out the array. Any suggestions?
----------------------
function parse_qnas($string, $path, $start_flag )
{
global $aNEW;
$Pat1 = "Q";
$Pat2 = "?";
$aTmp = array();
$ret1 = gsr_match_case_sensitive($string, $Pat1);
$ret2 = gsr_match($string, $Pat2);
if( $ret1 && $ret2 )
{
if( $start_flag == false )
{
echo "<P>First QnA found! Don't write array!";
$start_flag = true;
}
if( $start_flag == true )
{
echo "<P>Second QnA found! Write array!";
write_array( $aNEW );
$aNEW = zero_array( $aNEW );
}
}
$aNEW[] = $string;
return;
}