Solved

Parse MySQL data into an array

Posted on 2013-10-24
2
301 Views
Last Modified: 2013-10-24
I am using Wordpress which uses MySQL.

One of the plugins stores data in this format:

[["","","Member Name","Total Points"],["1.","","Player 1","80"],["2.","PC","Player 2","60"],["3.","","Player 3","60"]]

Open in new window


This data represents four columns in a table which I need to parse into an array for my custom application.
0
Comment
Question by:mcnuttlaw
2 Comments
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 500 total points
ID: 39596867
The data is in JSON format so you can use the json_decode function to get an array:

$str = '[["","","Member Name","Total Points"],["1.","","Player 1","80"],["2.","PC","Player 2","60"],["3.","","Player 3","60"]]';
$myArray = json_decode($str);
var_dump($myArray);

Open in new window

0
 
LVL 109

Expert Comment

by:Ray Paseur
ID: 39597125
Bookmark this: http://www.json.org/
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question