0

I have a website which is running in Joomla 2.5 with MyBlog. I am creating a external application which takes data from MyBlog tables and displays to website users.

In MyBlog comment tables, there is a column name 'comment_author_data'. In this column the data inside looks something like this: {"name":"xxxxx","email":"[email protected]","id":"xxx"}

I want to access the value from the name and Email Id and Id from the data.

How do I access them using PHP ?

Any help will be appreciated.

2
  • have you tried something yet? Commented Oct 28, 2013 at 10:11
  • look at how to import the Joomla framework externally and how to write a query to get data from a Joomla database table. There are more than enough docs for this. If you encounter a specific problem with your code and provide examples of what you've tried, you will more likely get an answer ;) Commented Oct 28, 2013 at 10:14

1 Answer 1

2

That looks like a json string. you can access the values of name and email by using json_decode().

<?php 

$string = ' {"name":"xxxxx","email":"[email protected]","id":"xxx"}';

$data = json_decode($string);

print_r($data);

?>

returns

stdClass Object
(
    [name] => xxxxx
    [email] => [email protected]
    [id] => xxx
)

which allows you to access it like so:

print $data->name;

Sign up to request clarification or add additional context in comments.

2 Comments

Hi dbh, thank for your solution.... it really worked for me.... really appreciated the quick reply...
@mkb no worries mate, glad this helped you and solved your issue!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.