Solved

Parse MySQL data into an array

Posted on 2013-10-24
2
298 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 42

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

759 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

15 Experts available now in Live!

Get 1:1 Help Now