Skip to content

Tag: php

PHP convert XML to JSON

I am trying to convert xml to json in php. If I do a simple convert using simple xml and json_encode none of the attributes in the xml show. $xml = simplexml_load_file(“states.xml”); echo json_encode(…

Regex to find content of the last occurence of square brackets

Hi Everybody, I’m Currently using preg_match and I’m trying to extract some informations enclosed in square brackets. So far, I have used this: /[(.*)]/ But I want it to be only the content of the last occurence – or the first one, if starting from the end! In the following: string = “…