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

    // 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

    // make it json format
    echo json_encode(

Recommended Answers

Not something I'm familiar with but https://forum.sencha.com/forum/showthread.php?99649-SOLVED-JSON-response-with-keys-that-contain-quot-quot-hyphen-character-ref-error looks to mention this along with why and a possible fix.

Jump to Post

All 2 Replies

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 learning and sharing knowledge.