I got a result set in array format and i want to make square bracket value as a key and the other one as a value
here is my code
[Name]asdasdasd [Email]dfgdfg@in.com [Phone Number]42342342342 [Subject]dsafsdfsd [Company Name]ZXZXZX [Country]Antarctica
i want output like :- array("name"=>"asdasdasd", "Email"=>"dfgdfg@in.com");
how can i do this in PHP any help would be greatly appreciated
Thanks Jassi
You could do:
The regex is a bit more complicated looking, but it basically matches anything but [], allows whitespace in the value and makes sure that the last character isn’t [] or whitespace. You could probably get away with
([^\]\[\s]+)if you knew you were never going to have spaces.