Skip to content

Instantly share code, notes, and snippets.

@hedii
Last active March 4, 2019 10:19
Show Gist options
  • Select an option

  • Save hedii/320c5aa45e11ddd765e7 to your computer and use it in GitHub Desktop.

Select an option

Save hedii/320c5aa45e11ddd765e7 to your computer and use it in GitHub Desktop.

Revisions

  1. hedii revised this gist Apr 11, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,13 @@
    <?php

    /**
    * get_string_between function.
    *
    * Given a string ($string) and two delimiters ($start and $end), this function
    * returns the substring between $start and $end. $start and $end are also
    * removed.
    *
    * @link http://www.justin-cook.com/wp/2006/03/31/php-parse-a-string-between-two-strings/
    *
    * @access public
    * @param string $string
    @@ -18,6 +21,7 @@ function get_string_between($string, $start, $end){
    $ini = strpos($string, $start);
    if ($ini == 0) {
    return '';

    }
    $ini += strlen($start);
    $len = strpos($string, $end, $ini) - $ini;
  2. hedii created this gist Apr 11, 2015.
    26 changes: 26 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    <?php
    /**
    * get_string_between function.
    *
    * Given a string ($string) and two delimiters ($start and $end), this function
    * returns the substring between $start and $end. $start and $end are also
    * removed.
    *
    * @access public
    * @param string $string
    * @param string $start
    * @param string $end
    * @return string the string between $start and $end
    */
    function get_string_between($string, $start, $end){

    $string = ' ' . $string;
    $ini = strpos($string, $start);
    if ($ini == 0) {
    return '';
    }
    $ini += strlen($start);
    $len = strpos($string, $end, $ini) - $ini;
    return substr($string, $ini, $len);

    }