php拆分为preg_split错误

时间:2018-08-13 18:10:41

标签: split

嗨,我真的很难在这个旧的php函数中转换split函数,并且想知道是否有人可以帮助我?谢谢!

function prepare() {
    /* Wildcard Rules
     * SCALAR  (?) => 'original string quoted'
     * MISC    (~) => original string (left 'as-is')
     */
    $this->preparedquery = '';

    $data = func_get_args();
    $query = $data[ 0 ];

    // How do I convert this split to preg_split?
    $tokens = split( "[\?\~]", $query );

    $this->preparedquery = $tokens[ 0 ];
    $count = strlen( $tokens[ 0 ] );
    for ( $i = 1; $i < count( $tokens ); $i++ ) {
        $char = substr( $query, $count, 1 );
        $count += ( strlen( $tokens[ $i ] ) + 1 );

        $pdata = & $data[ $i ];

        $this->preparedquery .= ( $char != "~" ? quote_smart_html( $pdata ) : $pdata );
        $this->preparedquery .= $tokens[ $i ];
    }
    if ( $this->debug == '1' ) {
        echo $this->preparedquery;
        echo '<br>';
    }
}

0 个答案:

没有答案