hey every one thank you in advance
i have a jason resonse befofe the start of the json respone i get a hyphen like this
i have been stuck for a day here so any help is much appreciated

-{
    "responseCode": "",
    "responseStatus": "200",
    "responseMessege": "Success",
    "product": {
        "id": "60",
        "name": "Rolex Watch",
        "description": "Luxury watch.",
        "price": "25000",
        "category_id": "1",
        "category_name": "Fashion"
    }
}

the json encode part

if($product->name!=null){
    // create array
    $product_arr = array(
        "id" =>  $product->id,
        "name" => $product->name,
        "description" => $product->description,
        "price" => $product->price,
        "category_id" => $product->category_id,
        "category_name" => $product->category_name**Bold Text Here**

    );

    // set response code - 200 OK
    http_response_code(200);

    // make it json format
    echo json_encode(
        array(
        "responseCode"=>"",
        "responseStatus"=>"200",
        "responseMessege"=>"Success",
        "product"=>$product_arr));
}

Is it possible that you are echo'ing a - somewhere earlier in your app, before your echo json_encode() statement? What does the full PHP script for that page look like? If you comment out the echo statement that begins on line 17 of the code you provided, does it still print out the dash?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.