src/xPDO/xPDO.php
public static function escSplit($char, $str, $escToken = '`', $limit = 0) {
        $split= array();
        $charPos = strpos($str, $char);
        if ($charPos !== false) {
            if ($charPos === 0) {
                $searchPos = 1;
                $startPos = 1;
            } else {
                $searchPos = 0;
                $startPos = 0;
            }
            $escOpen = false;
            $strlen = strlen($str);
            for ($i = $startPos; $i <= $strlen; $i++) {
                if ($i == $strlen) {
                    $tmp= trim(substr($str, $searchPos));
                    if (!empty($tmp)) $split[]= $tmp;
                    break;
                }
                if ($str[$i] == $escToken) {
                    $escOpen = $escOpen == true ? false : true;
                    continue;
                }
                if (!$escOpen && $str[$i] == $char) {
                    $tmp= trim(substr($str, $searchPos, $i - $searchPos));
                    if (!empty($tmp)) {
                        $split[]= $tmp;
                        if ($limit > 0 && count($split) >= $limit) {
                            break;
                        }
                    }
                    $searchPos = $i + 1;
                }
            }
        } else {
            $split[]= trim($str);
        }
        return $split;
    }
public static function escSplit($char, $str, $escToken = '`', $limit = 0) {
        $split= array();
        $charPos = strpos($str, $char);
        if ($charPos !== false) {
            if ($charPos === 0) {
                $searchPos = 1;
                $startPos = 1;
            } else {
                $searchPos = 0;
                $startPos = 0;
            }
            $escOpen = false;
            $strlen = strlen($str);
            for ($i = $startPos; $i <= $strlen; $i++) {
                if ($i == $strlen) {
                    $tmp= trim(substr($str, $searchPos));
                    if (!empty($tmp)) $split[]= $tmp;
                    break;
                }
                if ($str[$i] == $escToken) {
                    $escOpen = $escOpen == true ? false : true;
                    continue;
                }
                if (!$escOpen && $str[$i] == $char) {
                    $tmp= trim(substr($str, $searchPos, $i - $searchPos));
                    if (!empty($tmp)) {
                        $split[]= $tmp;
                        if ($limit > 0 && count($split) >= $limit) {
                            break;
                        }
                    }
                    $searchPos = $i + 1;
                }
            }
        } else {
            $split[]= trim($str);
        }
        return $split;
    }
public static function escSplit ( $ char , $ str , $ escToken = '`' , $ limit = 0 ) { $ split = array ( ) ; $ charPos = strpos ( $ str , $ char ) ; if ( $ charPos !== false ) { if ( $ charPos === 0 ) { $ searchPos = 1 ; $ startPos = 1 ; } else { $ searchPos = 0 ; $ startPos = 0 ; } $ escOpen = false ; $ strlen = strlen ( $ str ) ; for ( $ i = $ startPos ; $ i <= $ strlen ; $ i ++ ) { if ( $ i == $ strlen ) { $ tmp = trim ( substr ( $ str , $ searchPos ) ) ; if ( ! empty ( $ tmp ) ) $ split [ ] = $ tmp ; break ; } if ( $ str [ $ i ] == $ escToken ) { $ escOpen = $ escOpen == true ? false : true ; continue ; } if ( ! $ escOpen && $ str [ $ i ] == $ char ) { $ tmp = trim ( substr ( $ str , $ searchPos , $ i - $ searchPos ) ) ; if ( ! empty ( $ tmp ) ) { $ split [ ] = $ tmp ; if ( $ limit > 0 && count ( $ split ) >= $ limit ) { break ; } } $ searchPos = $ i + 1 ; } } } else { $ split [ ] = trim ( $ str ) ; } return $ split ; }
Splits a string on a specified character, ignoring escaped content.

@static
@param string $char A character to split the tag content on.
@param string $str The string to operate on.
@param string $escToken A character used to surround escaped content; all
content within a pair of these tokens will be ignored by the split
operation.
@param integer $limit Limit the number of results. Default is 0 which is
no limit. Note that setting the limit to 1 will only return the content
up to the first instance of the split character and will discard the
remainder of the string.
@return array An array of results from the split operation, or an empty
array.
Splits a string on a specified character ignoring escaped content .