在搜索函数中使用PHP str_replace不会返回期望的结果

时间:2019-09-07 11:22:38

标签: php

在搜索功能中,我使用以下代码:

player.addListener(new Player.EventListener() {
    @Override
    public void onTimelineChanged(Timeline timeline, Object manifest, int reason) {


    }

    @Override
    public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {

    }

    @Override
    public void onLoadingChanged(boolean isLoading) {

    }

    @Override
    public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {

        if (playWhenReady && playbackState == Player.STATE_READY) {
            // Active playback.
        } else if (playbackState == Player.STATE_ENDED) {
            //The player finished playing all media

           //Add your code here

        } else if (playWhenReady) {
            // Not playing because playback ended, the player is buffering, stopped or
            // failed. Check playbackState and player.getPlaybackError for details.
        } else {
            // Paused by app.
        }

    }

    @Override
    public void onRepeatModeChanged(int repeatMode) {

    }

    @Override
    public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {

    }

    @Override
    public void onPlayerError(ExoPlaybackException error) {

    }

    @Override
    public void onPositionDiscontinuity(int reason) {
        //THIS METHOD GETS CALLED FOR EVERY NEW SOURCE THAT IS PLAYED
      //  int latestWindowIndex = player.getCurrentWindowIndex();


    }

    @Override
    public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {

    }

    @Override
    public void onSeekProcessed() {

    }
});

当我搜索关键字“电话” 时,它会返回正确的结果。 当我搜索关键字“ pho” 时,它还会返回正确的结果。

但是当我搜索关键字“电话” 时,它返回的结果为零。

此代码中我必须更改的内容

$mSearch =  Search::newInstance();
$query_results = (array) json_decode($mSearch->toJson());
$pattern = $query_results['sKeyword'];

$query_results['sKeyword'] = str_replace(' ', '*', $pattern) . '*';

所以搜索还返回包含关键字“ phones”中任何字母的结果吗?

0 个答案:

没有答案