Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7856467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:43:25+00:00 2026-06-02T20:43:25+00:00

Anyway knows about json encoding with totally arrange like this https://graph.facebook.com/4 like facebook graph?

  • 0

Anyway knows about json encoding with totally arrange like this https://graph.facebook.com/4 like facebook graph?

coz when i write json simply php echo json_encode this will come out {"id":"4","name":"Mark Zuckerberg","first_name":"Mark","last_name":"Zuckerberg","link":"https://www.facebook.com/zuck","username":"zuck","gender":"male","locale":"en_US"}

just a straight line… 😀 anyone knows about it? 😀 please share

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:43:28+00:00Added an answer on June 2, 2026 at 8:43 pm

    For PHP >=5.4.0, you can use JSON_PRETTY_PRINT option when using json_encode

    For PHP < 5.4.0, you can use code from a user contributed note in this page of PHP manual http://www.php.net/manual/en/function.json-encode.php#80339

    <?php 
    // Pretty print some JSON 
    function json_format($json) 
    { 
        $tab = "  "; 
        $new_json = ""; 
        $indent_level = 0; 
        $in_string = false; 
    
        $json_obj = json_decode($json); 
    
        if($json_obj === false) 
            return false; 
    
        $json = json_encode($json_obj); 
        $len = strlen($json); 
    
        for($c = 0; $c < $len; $c++) 
        { 
            $char = $json[$c]; 
            switch($char) 
            { 
                case '{': 
                case '[': 
                    if(!$in_string) 
                    { 
                        $new_json .= $char . "\n" . str_repeat($tab, $indent_level+1); 
                        $indent_level++; 
                    } 
                    else 
                    { 
                        $new_json .= $char; 
                    } 
                    break; 
                case '}': 
                case ']': 
                    if(!$in_string) 
                    { 
                        $indent_level--; 
                        $new_json .= "\n" . str_repeat($tab, $indent_level) . $char; 
                    } 
                    else 
                    { 
                        $new_json .= $char; 
                    } 
                    break; 
                case ',': 
                    if(!$in_string) 
                    { 
                        $new_json .= ",\n" . str_repeat($tab, $indent_level); 
                    } 
                    else 
                    { 
                        $new_json .= $char; 
                    } 
                    break; 
                case ':': 
                    if(!$in_string) 
                    { 
                        $new_json .= ": "; 
                    } 
                    else 
                    { 
                        $new_json .= $char; 
                    } 
                    break; 
                case '"': 
                    if($c > 0 && $json[$c-1] != '\\') 
                    { 
                        $in_string = !$in_string; 
                    } 
                default: 
                    $new_json .= $char; 
                    break;                    
            } 
        } 
    
        return $new_json; 
    } 
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to ask if anyone knows about reliability of File.Copy in a
Is there anyway for this PHP script to know what are the scripts or
I know this is a bit bleeding edge, but here's the question anyway: Given
I would like to know if there is anyway I can compare two columns
i know every web-developer hates this topic, but anyway... i found no good solution
I feel like every second question i ask here is relating to Facebook Connect
Alright, I know questions like this have probably been asked dozens of times, but
Either this this question isn't asked often (possible), everyone knows how to do it
I have a schema structured something like this: App = {}; App.Outer = Ember.Object.extend({
Most people are asking about migrating from J2ME to Android. I'm not. I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.