colap Posted October 31, 2011 Share Posted October 31, 2011 var_dump($var); displays this=> array(1) { [0]=> array(2) { ["wp_maybe_load_widgets"]=> array(2) { ["function"]=> string(21) "wp_maybe_load_widgets" ["accepted_args"]=> int(1) } ["wp_maybe_load_embeds"]=> array(2) { ["function"]=> string(20) "wp_maybe_load_embeds" ["accepted_args"]=> int(1) } } } array(1) { [10]=> array(2) { ["wp_cron"]=> array(2) { ["function"]=> string(7) "wp_cron" ["accepted_args"]=> int(1) } ["sanitize_comment_cookies"]=> array(2) { ["function"]=> string(24) "sanitize_comment_cookies" ["accepted_args"]=> int(1) } } } array(1) { [10]=> array(1) { ["preview_theme"]=> array(2) { ["function"]=> string(13) "preview_theme" ["accepted_args"]=> int(1) } } } array(1) { [10]=> array(1) { ["twentyeleven_setup"]=> array(2) { ["function"]=> string(18) "twentyeleven_setup" ["accepted_args"]=> int(1) } } } array(1) { [10]=> array(1) { ["kses_init"]=> array(2) { ["function"]=> string(9) "kses_init" ["accepted_args"]=> int(1) } } } array(4) { [0]=> array(2) { ["create_initial_post_types"]=> array(2) { ["function"]=> string(25) "create_initial_post_types" ["accepted_args"]=> int(1) } ["create_initial_taxonomies"]=> array(2) { ["function"]=> string(25) "create_initial_taxonomies" ["accepted_args"]=> int(1) } } [1]=> array(1) { ["wp_widgets_init"]=> array(2) { ["function"]=> string(15) "wp_widgets_init" ["accepted_args"]=> int(1) } } [5]=> array(1) { ["smilies_init"]=> array(2) { ["function"]=> string(12) "smilies_init" ["accepted_args"]=> int(1) } } [10]=> array(4) { ["_show_post_preview"]=> array(2) { ["function"]=> string(18) "_show_post_preview" ["accepted_args"]=> int(1) } ["kses_init"]=> array(2) { ["function"]=> string(9) "kses_init" ["accepted_args"]=> int(1) } ["wp_schedule_update_checks"]=> array(2) { ["function"]=> string(25) "wp_schedule_update_checks" ["accepted_args"]=> int(1) } ["_wp_admin_bar_init"]=> array(2) { ["function"]=> string(18) "_wp_admin_bar_init" ["accepted_args"]=> int(1) } } } array(2) { [10]=> array(1) { ["twentyeleven_widgets_init"]=> array(2) { ["function"]=> string(25) "twentyeleven_widgets_init" ["accepted_args"]=> int(1) } } [100]=> array(1) { ["0000000045af3aff00000000ff5da154_register_widgets"]=> array(2) { ["function"]=> array(2) { [0]=> object(WP_Widget_Factory)#173 (1) { ["widgets"]=> array(13) { ["WP_Widget_Pages"]=> &object(WP_Widget_Pages)#145 ( { ["id_base"]=> string(5) "pages" ["name"]=> string(5) "Pages" ["widget_options"]=> array(2) { ["classname"]=> string(12) "widget_pages" ["description"]=> string(33) "Your site’s WordPress Pages" } ["control_options"]=> array(1) { ["id_base"]=> string(5) "pages" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(12) "widget_pages" } ["WP_Widget_Calendar"]=> &object(WP_Widget_Calendar)#144 ( { ["id_base"]=> string( "calendar" ["name"]=> string( "Calendar" ["widget_options"]=> array(2) { ["classname"]=> string(15) "widget_calendar" ["description"]=> string(37) "A calendar of your site’s posts" } ["control_options"]=> array(1) { ["id_base"]=> string( "calendar" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(15) "widget_calendar" } ["WP_Widget_Archives"]=> &object(WP_Widget_Archives)#146 ( { ["id_base"]=> string( "archives" ["name"]=> string( "Archives" ["widget_options"]=> array(2) { ["classname"]=> string(14) "widget_archive" ["description"]=> string(44) "A monthly archive of your site’s posts" } ["control_options"]=> array(1) { ["id_base"]=> string( "archives" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(15) "widget_archives" } ["WP_Widget_Links"]=> &object(WP_Widget_Links)#180 ( { ["id_base"]=> string(5) "links" ["name"]=> string(5) "Links" ["widget_options"]=> array(2) { ["classname"]=> string(12) "widget_links" ["description"]=> string(13) "Your blogroll" } ["control_options"]=> array(1) { ["id_base"]=> string(5) "links" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(12) "widget_links" } ["WP_Widget_Meta"]=> &object(WP_Widget_Meta)#181 ( { ["id_base"]=> string(4) "meta" ["name"]=> string(4) "Meta" ["widget_options"]=> array(2) { ["classname"]=> string(11) "widget_meta" ["description"]=> string(43) "Log in/out, admin, feed and WordPress links" } ["control_options"]=> array(1) { ["id_base"]=> string(4) "meta" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(11) "widget_meta" } ["WP_Widget_Search"]=> &object(WP_Widget_Search)#182 ( { ["id_base"]=> string(6) "search" ["name"]=> string(6) "Search" ["widget_options"]=> array(2) { ["classname"]=> string(13) "widget_search" ["description"]=> string(27) "A search form for your site" } ["control_options"]=> array(1) { ["id_base"]=> string(6) "search" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(13) "widget_search" } ["WP_Widget_Text"]=> &object(WP_Widget_Text)#183 ( { ["id_base"]=> string(4) "text" ["name"]=> string(4) "Text" ["widget_options"]=> array(2) { ["classname"]=> string(11) "widget_text" ["description"]=> string(22) "Arbitrary text or HTML" } ["control_options"]=> array(3) { ["id_base"]=> string(4) "text" ["width"]=> int(400) ["height"]=> int(350) } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(11) "widget_text" } ["WP_Widget_Categories"]=> &object(WP_Widget_Categories)#184 ( { ["id_base"]=> string(10) "categories" ["name"]=> string(10) "Categories" ["widget_options"]=> array(2) { ["classname"]=> string(17) "widget_categories" ["description"]=> string(32) "A list or dropdown of categories" } ["control_options"]=> array(1) { ["id_base"]=> string(10) "categories" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(17) "widget_categories" } ["WP_Widget_Recent_Posts"]=> &object(WP_Widget_Recent_Posts)#185 (9) { ["id_base"]=> string(12) "recent-posts" ["name"]=> string(12) "Recent Posts" ["widget_options"]=> array(2) { ["classname"]=> string(21) "widget_recent_entries" ["description"]=> string(34) "The most recent posts on your site" } ["control_options"]=> array(1) { ["id_base"]=> string(12) "recent-posts" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(19) "widget_recent-posts" ["alt_option_name"]=> string(21) "widget_recent_entries" } ["WP_Widget_Recent_Comments"]=> &object(WP_Widget_Recent_Comments)#186 (9) { ["id_base"]=> string(15) "recent-comments" ["name"]=> string(15) "Recent Comments" ["widget_options"]=> array(2) { ["classname"]=> string(22) "widget_recent_comments" ["description"]=> string(24) "The most recent comments" } ["control_options"]=> array(1) { ["id_base"]=> string(15) "recent-comments" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(22) "widget_recent-comments" ["alt_option_name"]=> string(22) "widget_recent_comments" } ["WP_Widget_RSS"]=> &object(WP_Widget_RSS)#187 ( { ["id_base"]=> string(3) "rss" ["name"]=> string(3) "RSS" ["widget_options"]=> array(2) { ["classname"]=> string(10) "widget_rss" ["description"]=> string(33) "Entries from any RSS or Atom feed" } ["control_options"]=> array(3) { ["id_base"]=> string(3) "rss" ["width"]=> int(400) ["height"]=> int(200) } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(10) "widget_rss" } ["WP_Widget_Tag_Cloud"]=> &object(WP_Widget_Tag_Cloud)#188 ( { ["id_base"]=> string(9) "tag_cloud" ["name"]=> string(9) "Tag Cloud" ["widget_options"]=> array(2) { ["classname"]=> string(16) "widget_tag_cloud" ["description"]=> string(35) "Your most used tags in cloud format" } ["control_options"]=> array(1) { ["id_base"]=> string(9) "tag_cloud" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(16) "widget_tag_cloud" } ["WP_Nav_Menu_Widget"]=> &object(WP_Nav_Menu_Widget)#189 ( { ["id_base"]=> string( "nav_menu" ["name"]=> string(11) "Custom Menu" ["widget_options"]=> array(2) { ["classname"]=> string(15) "widget_nav_menu" ["description"]=> string(60) "Use this widget to add one of your custom menus as a widget." } ["control_options"]=> array(1) { ["id_base"]=> string( "nav_menu" } ["number"]=> bool(false) ["id"]=> bool(false) ["updated"]=> bool(false) ["option_name"]=> string(15) "widget_nav_menu" } } } [1]=> string(17) "_register_widgets" } ["accepted_args"]=> int(1) } } } array(1) { [10]=> array(1) { ["send_frame_options_header"]=> array(2) { ["function"]=> string(25) "send_frame_options_header" ["accepted_args"]=> int(0) } } } array(2) { [9]=> array(1) { ["wp_print_head_scripts"]=> array(2) { ["function"]=> string(21) "wp_print_head_scripts" ["accepted_args"]=> int(1) } } [10]=> array(1) { ["noindex"]=> array(2) { ["function"]=> string(7) "noindex" ["accepted_args"]=> int(1) } } } array(1) { [10]=> array(1) { ["wp_just_in_time_script_localization"]=> array(2) { ["function"]=> string(35) "wp_just_in_time_script_localization" ["accepted_args"]=> int(1) } } } How can i get the output with newline formatted ? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted October 31, 2011 Share Posted October 31, 2011 Output <pre> </pre> tags around the print_r/var_dump statement. Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted October 31, 2011 Share Posted October 31, 2011 try: echo "<pre>"; var_dump($var); echo "</pre>"; Output <pre> </pre> tags around the print_r/var_dump statement. beat me to it. Quote Link to comment Share on other sites More sharing options...
colap Posted October 31, 2011 Author Share Posted October 31, 2011 Output <pre> </pre> tags around the print_r/var_dump statement. Can you post the full code ? Quote Link to comment Share on other sites More sharing options...
colap Posted October 31, 2011 Author Share Posted October 31, 2011 try: echo "<pre>"; var_dump($var); echo "</pre>"; Output <pre> </pre> tags around the print_r/var_dump statement. beat me to it. Is there any shortcut way to write these three lines ? echo '<pre>'; var_dump($var); echo '</pre>'; Quote Link to comment Share on other sites More sharing options...
MasterACE14 Posted October 31, 2011 Share Posted October 31, 2011 not really, guess you could make your own function if you're using var_dump a lot? function custom_vardump($var) { $var_dump = ''; if(isset($var)) { $var_dump .= "<pre>"; $var_dump .= var_dump($var); $var_dump .= "</pre>"; } else { $var_dump .= "Variable doesn't exist!"; } return $var_dump; } $somerandomvar = array("somekey" => 'somevar'); echo custom_vardump($somerandomvar); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.