Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to use json_encode() function in php ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 127
    Comment on it

    Hi Reader's,
    Welcome to FindNerd, today we are going to discuss how to use json_encode() function in php ?

    So, Firstly let us know what is the use of json_encode() function ?

    JSON stands for JavaScript Object Notation. json_encode() is a PHP function that is used for converting the array given as its argument into a JSON string.

    you can see bellow example:

    <?php
    
    //First you need a PHP array of data
    $data = array(
        'first_name'    =>    "mac",
        'last_name'    =>    "heneary",
        'phone_number'    =>    123456789,
        'address'    =>    "adayu"
    
    );
    //here call json_encode() function
    $jsondata = json_encode($data);
    //print json_encode data
    print_r($jsondata);
    
    ?>
    

    output will come following of above example

    {"name":"mac","phone_number":123456789,"address":"adayu"}

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: