src/Lib/StringTool.php
public static function get_value_between_chars($haystack, $index = 0, $opening_char = '[', $closing_char = ']')
	{
	    $offset = 0;
	    $found = true;
	    $value = null;
	 
	    for ($i = 0; $i < $index + 1; $i++)
	    {
	        $op_pos = strpos($haystack, $opening_char, $offset);
	        if($op_pos !== false)
	        {
	            $cl_pos = strpos($haystack, $closing_char, $op_pos + strlen($opening_char));
	 
	            if($cl_pos !== false)
	            {
	                $value = substr($haystack, $op_pos + strlen($opening_char), $cl_pos - $op_pos - strlen($opening_char));
	                $offset = $cl_pos + strlen($closing_char);
	            }
	            else
	            {
	                $found = false;
	                break;
	            }
	        }
	        else
	        {
	            $found = false;
	            break;
	        }
	    }
	 
	    if($found)
	    {
	        return $value;
	    }
	    else
	    {
	        return null;
	    }
	}
public static function get_value_between_chars($haystack, $index = 0, $opening_char = '[', $closing_char = ']')
	{
	    $offset = 0;
	    $found = true;
	    $value = null;
	 
	    for ($i = 0; $i < $index + 1; $i++)
	    {
	        $op_pos = strpos($haystack, $opening_char, $offset);
	        if($op_pos !== false)
	        {
	            $cl_pos = strpos($haystack, $closing_char, $op_pos + strlen($opening_char));
	 
	            if($cl_pos !== false)
	            {
	                $value = substr($haystack, $op_pos + strlen($opening_char), $cl_pos - $op_pos - strlen($opening_char));
	                $offset = $cl_pos + strlen($closing_char);
	            }
	            else
	            {
	                $found = false;
	                break;
	            }
	        }
	        else
	        {
	            $found = false;
	            break;
	        }
	    }
	 
	    if($found)
	    {
	        return $value;
	    }
	    else
	    {
	        return null;
	    }
	}
public static function get_value_between_chars ( $ haystack , $ index = 0 , $ opening_char = '[' , $ closing_char = ']' ) { $ offset = 0 ; $ found = true ; $ value = null ; for ( $ i = 0 ; $ i < $ index + 1 ; $ i ++ ) { $ op_pos = strpos ( $ haystack , $ opening_char , $ offset ) ; if ( $ op_pos !== false ) { $ cl_pos = strpos ( $ haystack , $ closing_char , $ op_pos + strlen ( $ opening_char ) ) ; if ( $ cl_pos !== false ) { $ value = substr ( $ haystack , $ op_pos + strlen ( $ opening_char ) , $ cl_pos - $ op_pos - strlen ( $ opening_char ) ) ; $ offset = $ cl_pos + strlen ( $ closing_char ) ; } else { $ found = false ; break ; } } else { $ found = false ; break ; } } if ( $ found ) { return $ value ; } else { return null ; } }
Return the string found between two characters. If an index is given, it returns the
value at the index position

@param string $opening_char
@param string $closing_char
@param int $index 0 based index
@return string or null
Return the string found between two characters . If an index is given it returns the value at the index position