Question : PHP string function needed (custom loop to match nested begin-end pairs)

It's a long story for the context, but due to the possibly imperfect strings this function needs to handle, i need to do this manually/simply.   I've sketched out a function below - can someone fill in the details to help me?

Goal: return the string excerpt that encompasses the  (hierarchically) matching  end lexeme.
sample input data:
BEGIN...
  BEGIN...
  END...
  BEGIN...
  END...
END...
EXTRA MORE STUFF HERE AT END THAT IS TO BE CHOPPED OFF

function extract_until_matching_lexeme($Source, $Begin, $End)
{ // $Source is source string, and $Begin, $End are the keyword lexemes being used
// return the string up until the matching bookend

$Count = 0;  //Push/Pop stack level of nesting
$Pos =0;  // inching along position within string for where we last left off parsing
$Size = str_size($Source);

DO
// find next Begin OR End     -(note this gets us started for the first BEGIN, which there'll always be at least one outer BEGIN level)

//Record Position where to start next loop iteration

//if BEGIN then $Count++    If END  then $Count--

UNTIL ($Count==0  OR  $Pos>=$Size)

RETURN  substr($Source, 0, $Pos)
}// end function


thanks!

Answer : PHP string function needed (custom loop to match nested begin-end pairs)

right but any double remote is probably going to create an infinite loop on video

hey you might be able to use rdp, options, local resources, bring plug and play/serial stuff with me

load the drivers on computer B, and install the guitar software on computer B, and hope it detects the guitar thru usb/serial (?)

it's going to sound crappy if that works though.
Random Solutions  
 
programming4us programming4us