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 7032121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:53:36+00:00 2026-05-28T00:53:36+00:00

How can I pretty print into a div a json string assigned to smarty?

  • 0

How can I pretty print into a div a json string assigned to smarty?

i know i can run php functions in smarty, so maybe a custom function will work?

thanks in advance.

  • 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-05-28T00:53:37+00:00Added an answer on May 28, 2026 at 12:53 am

    The easiest thing to do is to convert the object to an associative array, and then parse it. The function would look like this:

    function format_json($array, $indent) {
    
        $indent_text = '';
    
        for ($ii = 0;$ii < $indent; $ii++)
            $indent_text .= '    ';
    
        echo '<br />'.$indent_text.'{<br />';
    
        foreach ($array as $key => $value) {
            echo $indent_text.'"'.$key.'" : '; 
            if (is_array($value))
                format_json( $value, $indent + 1 );
            else echo '"'.$value.'"; <br />';
        }
        echo $indent_text.'}<br />';
    }
    
    <pre><code><?php format_json(json_decode($your_json_object, true), 0); ?></code></pre>
    

    Obviously, you can style the tag and change the indentation any way you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can currently use sgml-pretty-print to pretty print an xml file in emacs, but
Pretty simple question, how can I transform a number (1, 2, 3, etc) into
Is there a good .NET file syncing library? It can be pretty basic and
In MatLab, you can declare symbols pretty easily: syms a,b mat = [a,b] I'm
I'm a pretty inexperienced programmer (can make tk apps, text processing, sort of understand
I can read the MySQL documentation and it's pretty clear. But, how does one
So this seems pretty basic but I can't get it to work. I have
I'm pretty sure it's easy but I can't seem to find it. I have
I'm pretty darn new to C# and I can't figure out how to express
The title pretty much sums it up: How can I get the server IP

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.