Jump to content


Photo

How to style PHP Function (Array)


  • Please log in to reply
5 replies to this topic

#1 laural

laural

    Member

  • Members
  • PipPip
  • 11 posts

Posted 18 January 2013 - 07:13 AM

I have a forum that is included on my site via SSI. There is a function provided that allows me to pull in the Member name (based on a member id) - and I can print the array of profile information. I need to format and display this information and I don't know how to do that... can anyone point me in the right direction? BTW, I cannot add anything to the function... Thank you!

Array
(
    [13] => Array
	    (
		    [username] => laural
		    [name] => laural
		    [id] => 13
		    [is_buddy] =>
		    [is_reverse_buddy] =>
		    [buddies] => Array
			    (
			    )
		    [title] =>
		    [href] => http://www.powerflexweb.com/pwf/forum/index.php?action=profile;u=13
		    [link] => laural
		    [email] => laura-long@nc.rr.com
		    [show_email] => no
		    [registered] => January 16, 2013, 02:14:18 pm
		    [registered_timestamp] => 1358363658
		    [blurb] =>
		    [gender] => Array
			    (
				    [name] =>
				    [image] =>
			    )
		    [website] => Array
			    (
				    [title] =>
				    [url] =>
			    )
		    [birth_date] => 0000-00-00
		    [signature] =>
		    [location] =>
		    [icq] => Array
			    (
				    [name] =>
				    [add] =>
				    [href] =>
				    [link] =>
				    [link_text] =>
			    )
		    [aim] => Array
			    (
				    [name] =>
				    [href] =>
				    [link] =>
				    [link_text] =>
			    )
		    [yim] => Array
			    (
				    [name] =>
				    [href] =>
				    [link] =>
				    [link_text] =>
			    )
		    [msn] => Array
			    (
				    [name] =>
				    [href] =>
				    [link] =>
				    [link_text] =>
			    )
		    [real_posts] => 0
		    [posts] => 0
		    [avatar] => Array
			    (
				    [name] =>
				    [image] =>
				    [href] =>
				    [url] =>
			    )
		    [last_login] => January 16, 2013, 02:39:08 pm
		    [last_login_timestamp] => 1358365148
		    [karma] => Array
			    (
				    [good] => 0
				    [bad] => 0
				    [allow] =>
			    )
		    [ip] => 173.95.174.124
		    [ip2] => 173.95.174.124
		    [online] => Array
			    (
				    [is_online] =>
				    [text] => Offline
				    [href] => http://www.powerflexweb.com/pwf/forum/index.php?action=pm;sa=send;u=13
				    [link] => Offline
				    [image_href] => http://www.powerflexweb.com/pwf/forum/Themes/pwf/images/useroff.gif
				    [label] => Offline
			    )
		    [language] =>
		    [is_activated] => 1
		    [is_banned] =>
		    [options] => Array
			    (
				    [display_quick_reply] => 1
			    )
		    [is_guest] =>
		    [group] =>
		    [group_color] =>
		    [group_id] => 0
		    [post_group] => Newbie
		    [post_group_color] =>
		    [group_stars] => *
		    [warning] => 0
		    [warning_status] =>
		    [local_time] => January 18, 2013, 07:11:39 am
		    [has_messenger] =>
	    )
)


#2 kicken

kicken

    Wiser? Not exactly.

  • Gurus
  • 2,637 posts
  • LocationBonita, FL

Posted 18 January 2013 - 08:15 AM

There is no way you're going to format PHP's print_r output into something presentable to an end-user using css.  print_r is for debugging use only.  You need to be able to use PHP to get the information and format it that way.
Recycle your old CD's, don't trash them!
Did I help you out?  Feeling generous? I accept tips via Paypal or Bitcoin @ 14mDxaob8Jgdg52scDbvf3uaeR61tB2yC7

#3 laural

laural

    Member

  • Members
  • PipPip
  • 11 posts

Posted 18 January 2013 - 09:46 AM

I had a bad feeling that would be the answer :) Thanks, I appreciate the confirmation!

#4 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 18 January 2013 - 11:27 AM

Does the function return an array which you then put into print_r or does the function actually call print_r?
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!

#5 laural

laural

    Member

  • Members
  • PipPip
  • 11 posts

Posted 18 January 2013 - 01:50 PM

Jessica,
The function does return an array - I put it in print_r to "see" the array... anything I can do to format?

#6 Jessica

Jessica

    This is not my name.

  • Gurus
  • 8,982 posts
  • LocationDallas, TX
  • Age:26

Posted 18 January 2013 - 01:53 PM

Yes. Stop using print_r. Figure out how you want it to look.
My goal in replying to posts is to help you become a better programmer, including learning how to debug your own code and research problems. For that reason, rather than posting the solution, I reply with tips and hints on how to find the solution yourself. See below for useful links when you get stuck.

How to Get Good Help: How to Ask Questions | Don't be a help vampire
Debugging Your Code: Debugging your SQL | What does a php function do? | What does a term mean? | Don't see any errors?
Things You Should Do: Normalize Your Data | use print_r() or var_dump()
Lulz: "Functions should not have side effects." - trq

Please take a look at my new PHP/Web Dev blog: The Web Mason - Thanks!!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com