Simple Solution To Minify Data From Different Locations
Filed under PHP
Lets say you use a forum software and a blogging software as the backend of your website. Lets also say that you want to create profiles for your members, but neither the forum or the blog software have the support you in, and in addition you need info from both the blog and the forum.
Instead of having two different arrays of data to show a user’s information, you can combine both arrays together with array_merge(). This is one of my favorite php functions as it really saves you hassles.
This:
echo $forum_array['name']." - ".$blog_array['blogpost_count'];
Can become:
echo $user['name']." - ".$user['blogpost_count'];
Not only is it already shorter, but there is less to have to remember. All the data is right there. And to do that all you would need to do is:
$user = array_merge($forum_array,$blog_array);
Of course array_merge() can be used for other things as well, such as combining POST and GET data into a single array (which hopefully you would run an XSS check on it all).
June 22nd, 2008 at 7:22 am
Your text is unreadable :( Dark gray on black is tough to read lol!