PHP JSON

elajani

Well-known member
  • Oct 18, 2020
    10,555
    6,335
    113
    $myArr = array(23, 45, 67, 23); Array eka

    encode

    $myJSON["data"] = json_encode($myArr);

    result

    {"data":"[23,45,67,23]"}

    how to remove "[23,45,67,23]" double Quotes
     
    • Like
    Reactions: TNHM

    Lakshan-Seram

    Well-known member
  • May 31, 2011
    24,714
    12,619
    113
    127.0.0.1:8080/Kandy
    PHP:
    <?php
    $myArr = array( 'data' => array(23, 45, 67, 23));
    $json = json_encode( $myArr );
    ?>

    PHP:
    <?php
    header('Content-Type: application/json; charset=utf-8');
    $myArr = array( 'data' => array(23, 45, 67, 23));
    $json = json_encode( $myArr );
    echo $json;
    ?>


    image.png

    ------ Post added on Oct 3, 2021 at 11:50 AM
     

    elajani

    Well-known member
  • Oct 18, 2020
    10,555
    6,335
    113
    Thank
    PHP:
    <?php
    $myArr = array( 'data' => array(23, 45, 67, 23));
    $json = json_encode( $myArr );
    ?>

    PHP:
    <?php
    header('Content-Type: application/json; charset=utf-8');
    $myArr = array( 'data' => array(23, 45, 67, 23));
    $json = json_encode( $myArr );
    echo $json;
    ?>


    image.png

    ------ Post added on Oct 3, 2021 at 11:50 AM
    Thank You vary much Brother