I want to convert following string into json. Following has a link to image then delimiter ',' then a link then a delimiter ',' then has another delimiter ',' between title and subtitle then another delimiter '#'.
$str = "http://example.com/1.jpg,http://example.com/1.html,title,subtitle#http://example.com/2.jpg,http://example.com/2.html,title,subtitle#http://example.com/3.jpg,http://example.com/3.html,title,subtitle";
I want above string to appear like following
[
{
image: http://example.com/1.jpg,
link: http://example.com/1.html,
title: title,
subtitle: subtitle
},
{
image: http://example.com/2.jpg,
link: http://example.com/2.html,
title: title,
subtitle: subtitle
},
{
image: http://example.com/3.jpg,
link: http://example.com/3.html,
title: title,
subtitle: subtitle
}
]
How can I achieve above in php?