TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-14-2009, 09:47 AM   #1 (permalink)
That guy
 
cachepl0x's Avatar
 
Join Date: Sep 2009
Location: San Antonio, TX
Posts: 24
Thanks: 0
cachepl0x is on a distinguished road
Default Simple, bored, probably useless.

Well, I haven't had any sleep (woot 26 hours), and I found that PHP's json decode was not simple, nor clean enough for my taste, so I made an incredibly simple, probably useless function for it.

PHP Code:
function jsonParse ($file$col) {
    
$json file_get_contents($file);
    
$obj  json_decode($json);
    return 
$obj->{$col};

And you would use it like this:

PHP Code:
jsonParse ('settings.json''name'); 
Assuming you have a file called "settings.json," and let's just get an example for it:

Code:
{
    "host" : "localhost",
    "user" : "marc",
    "pass" : "lolmypass",
    "name" : "database name"
}

Last edited by cachepl0x : 10-14-2009 at 09:57 AM. Reason: Changed double quotes to single quotes
cachepl0x is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Simple Currency Converter with Automatic Symbols Wildhoney General 11 03-16-2010 05:22 PM
Simple Image Uploader TerrorRonin Script Giveaway 8 06-18-2008 01:22 PM
Bored.... what do webmasters need that they are missing? drewbee General 13 05-23-2008 04:13 PM
Simple PHP Login and Register System! Alex.Prisoner Advanced PHP Programming 1 04-12-2008 10:32 AM
Simple Email Validation Gareth Script Giveaway 3 02-21-2008 01:23 PM


All times are GMT. The time now is 12:32 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design