11:42:05 PM
Wednesday
Sep 08
Su M Tu W Th F Sa
567891011
12131415161718
19202122232425
262728293012
3456789

Play My Typing Game

View Some of My Artwork

String Chopping Functions
These are some string functions I wrote one night.

<?
## find everything before
function FindAllBefore($str, $delimit) {
        if(strpos($str, $delimit) === false) { return false; }
        else {
           $pos1 = 0;
           $pos2 = strpos($str, $delimit);
           return substr($str, $pos1, $pos2);
  }     
}
## find everything before, including
function FindAllBeforeIncluding($str, $delimit) {
        if(strpos($str, $delimit) === false) { return false; }
        else {
           $pos1 = 0;
           $pos2 = strpos($str, $delimit)+strlen($delimit);
           return substr($str, $pos1, $pos2);
  }     
}
## find everything after
function FindAllAfter($str, $delimit) {
        if(strpos($str, $delimit) === false) { return false; }
        else {
           $pos1 = strpos($str, $delimit)+strlen($delimit);
           $pos2 = strlen($str);
           return substr($str, $pos1, $pos2);
  }     
}
## find everything after, including
function FindAllAfterIncluding($str, $delimit) {
        if(strpos($str, $delimit) === false) { return false; }
        else {
           $pos1 = strpos($str, $delimit);
           $pos2 = strlen($str);
           return substr($str, $pos1, $pos2);
  }     
}

## find inside, including
function FindInsideIncluding($str, $start, $end) {
        if(strpos($str, $start) === false) { return false; }
        else if (strpos($str, $end) === false) { return false; }
        else {
           $pos1 = strpos($str, $start);
           $pos2 = strpos(FindAllAfter($str, $start), $end)+strlen($end)+strlen($start);
           return substr($str, $pos1, $pos2);
  }     
}


## find inside
function FindInside($str, $start, $end) {
        if(strpos($str, $start) === false) { return false; }
        else if (strpos($str, $end) === false) { return false; }
        else {
           $pos1 = strpos($str, $start)+strlen($start);
           $pos2 = strpos(FindAllAfter($str, $start), $end);
           return substr($str, $pos1, $pos2);
  }     
}
?>


Read Previous:
Writing a Text File
Read Next:
Create a Random String
Table of Contents


Give a listen to my music...
My Best Recordings
How my services and skills can help you:
  • Global (via Email/Skype/AIM(ichat)/Yahoo)
    • Web Development Consulting
    • Custom Web App Development (PHP/MySQL/jQuery/CSS) Cross-Browser & OS
    • Cellphone App Development (Android/MobileWeb)
    • Music Lessons & Education for Beginner Guitar, Piano, Bass, which transfers over to many other instruments I am comfortable playing but not yet at teaching.
    • Music - Soundtrack Composition & Voice Work
  • Local
    • Most all the above, but also:
      • Music Performance (Harp, Voice, Guitar, Piano, Bass, Latin Percussion)
      • Recording Live Music Audio
      • Video Streaming live music and other live events anywhere that can provide wifi
      • Training Video Streaming to your venue's trusted soundperson
Skills:
  • Global (via Email/Skype/AIM(ichat)/Yahoo)
    • Web Development Consulting
    • Custom Web App Development (PHP/MySQL/jQuery/CSS) Cross-Browser & OS
    • Cellphone App Development (Android/MobileWeb)
    • Music Lessons & Education for Beginner Guitar, Piano, Bass, which transfers over to many other instruments I am comfortable playing but not yet at teaching.
    • Music - Soundtrack Composition & Voice Work
  • Local, Most all the above, but also:
    • Music Performance (Harp, Voice, Guitar, Piano, Bass, Latin Percussion)
    • Being your venue's soundman
    • Video Streaming live music and other live events anywhere that can provide wifi
    • Training Video Streaming to your venue's trusted soundperson