Help extracting sentences from block of text..

What kind of code would I need in order to take exactly what I want from this block of text.
I just want to extract names and messages… maybe i need some help with numerical literals to create a complex pattern to search for but i’m really not sure.
Ok so here is the text:


{
“data”: [
{
“id”: “572502175_141659879224245”,
“from”: {
“name”: “Ali Ryan”,
“id”: “572502175”
},
“message”: “no more flu means I HAVE to start my FYP… :(”,
“actions”: [
{
“name”: “Comment”,
“link”: “http://www.facebook.com/572502175/posts/141659879224245
},
{
“name”: “Like”,
“link”: “http://www.facebook.com/572502175/posts/141659879224245
}
],
“type”: “status”,
“created_time”: “2011-01-05T15:38:12+0000”,
“updated_time”: “2011-01-05T15:51:59+0000”,
“likes”: 1,
“comments”: {
“data”: [
{
“id”: “572502175_141659879224245_1194858”,
“from”: {
“name”: “Ali Ryan”,
“id”: “572502175”
},
“message”: “ha you’re slightly evil”,
“created_time”: “2011-01-05T15:51:13+0000”
},
{
“id”: “572502175_141659879224245_1194864”,
“from”: {
“name”: “Conor Brosnahan”,
“id”: “810195525”
},
“message”: “E-vul?\n\nhttp://www.youtube.com/watch?v=7edeOEuXdMU”,
“created_time”: “2011-01-05T15:51:59+0000”,
“likes”: 1
}
],
“count”: 9
}
},
{
“id”: “1169931381_1616293365120”,
“from”: {
“name”: “Holly Ni Ghrada”,
“id”: “1662583590”
},
“to”: {
“data”: [
{
“name”: “Joey Kelly”,
“id”: “1169931381”
}
]
},
“message”: “nollaig shona agus ath bhlian faoi mhaise! when ya back up to limerick for hard work on the fyp?! bottles of f\u00edon dearg are awaiting us buddy!!”,
“actions”: [
{
“name”: “Comment”,
“link”: “http://www.facebook.com/1169931381/posts/1616293365120
},
{
“name”: “Like”,
“link”: “http://www.facebook.com/1169931381/posts/1616293365120
}
],
“type”: “status”,
“created_time”: “2011-01-03T21:02:53+0000”,
“updated_time”: “2011-01-04T18:24:05+0000”,
“comments”: {
“data”: [
{
“id”: “1169931381_1616293365120_913192”,
“from”: {
“name”: “Joey Kelly”,
“id”: “1169931381”
},
“message”: “Mar an c\u00e9anna duitse Holly! Hope ye had a good one! I was gona go back soon but wanadem water tanks in the attic of our gaff in Thomand burst over the christmas, and now the place smells like a hamster cage, so I might hold off for a bit! Maybe towards the end den seachtain seo chugainn. We certainly must clink a few bottles soon! Are you above in Limerick?”,
“created_time”: “2011-01-04T16:37:00+0000”
}


And what I would like to print out from that is something like this:

Name: Ali Ryan
Message: no more flu means I HAVE to start my FYP.... :(

Name: Ali Ryan
Message: ha you're slightly evil

Name: Conor Brosnahan
Message: E-vul?\n\nhttp://www.youtube.com/watch?v=7edeOEuXdMU

Name: Holly Ni Ghrada

Name: Joey Kelly
Message: nollaig shona agus ath bhlian faoi mhaise! when ya back up to limerick for hard work on the fyp?! bottles of f\u00edon dearg are awaiting us buddy!!

Could somebody please help me out?

hi mate :slight_smile:

From what i can see your info is collected into arrays called ‘data’

to access the info required something like this would suffice:
[sup]
echo $data[‘name’];
echo $data[‘message’];
[/sup]
would print the name and message… however…
if there is more than one row of info stored in ‘data’ then put it in a while loop:
something like this would suffice:

[sup]
while($data)
{
echo $data[‘name’];
echo $data[‘message’];
}
[/sup]
will print out the name and message for every row of data you have…

hope this helps :wink:

Thanks for the reply but the info displayed is actually just a text file. I need a way to strip it down to just the names and messages…?

Sponsor our Newsletter | Privacy Policy | Terms of Service