Solved

Parse MySQL data into an array

Posted on 2013-10-24
2
299 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 108

Expert Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now