preg_match help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dimxasnewfrozen
Forum Commoner
Posts: 84
Joined: Fri Oct 30, 2009 1:21 pm

preg_match help

Post by dimxasnewfrozen »

So I have a result from an API call and my skills in regular expressions and preg_match() are limited.

The result looks like this:
[{"county_name":"Albany","description":null"}]

This obviously doesn't work because I'm not too good with regex stuff

Code: Select all

if (preg_match('{"county_name":"', $content, $result))  {
            	$county = $result[1];
}
So I need the county name out of the string.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: preg_match help

Post by Celauran »

Looks like JSON, so you may want to take a peek at json_decode().
Post Reply