-2

我从 json 提供服务,但在 json 中显示 url 时遇到问题,这个 url http://git.drieanto.net/LagiDimanaAPI/index.php/user/get_following/1我尝试从数据库中显示 url 但在 json show 中显示"avatar":"http:\/\/git.drieanto.net\/LagiDimanaAPI\/assets\/image\/avatar\/edwin.png"

如何显示这样的普通网址http://git.drieanto.net/LagiDimanaAPI/assets/image/avatar/edwin.png

我用codeigniter这个代码

function get_following($id_follower) {
        if ($this->muser->cek_following($id_follower) == TRUE) {
            $query = $this->muser->get_list_id($id_follower);

            $feedback["following"] = array();

            foreach ($query->result() as $row) {

                $query_list_user = $this->muser->get_all_name_user_from_id($row->id_user);

                if ($query_list_user->num_rows() > 0) {

                    $row_ = $query_list_user->row();

                    $query_status = $this->muser->get_status($row_->id_user);
                    $query_status->num_rows();
                    $row2 = $query_status->row();
                    $response['status'] = $row2->status;

                    $response['regid'] = $row_->regid;

                    $response['id_user'] = $row_->id_user;

                    $response['email'] = $row_->email;

                    $response['nama'] = $row_->nama;

                    $response['jenis_kelamin'] = $row_->jenis_kelamin;

                    $response['tanggal_lahir'] = $row_->tanggal_lahir;

                    $response['instansi'] = $row_->instansi;

                    $response['jabatan'] = $row_->jabatan;

$response['avatar'] = $row_->avatar;

                    $feedback['success'] = 1;
                } else {

                    $feedback['success'] = 0;
                }
                array_push($feedback["following"], $response);
            }
            $feedback['success'] = 1;
            echo json_encode($feedback);
        } else {
            $feedback['success'] = 0;
            echo json_encode($feedback);
        }
    }

谢谢

4

1 回答 1

0

它只是逃避正斜杠。您可以使用str_replace($search_char, $replace_char, $string_to_search),删除它们。

$stuff = json_decode($response);
$url = str_replace("\\", "", $stuff['url']);

听起来您确实没有解码 JSON,因为我相信 PHP 会自动为您解除所有这些内容。

于 2013-06-06T17:14:04.597 回答