Hi,
to get familiar with the function "strpos(haystack, needle, offset)" you may read this
[url]
www.php.net/manual/en/function.strpos.php
[/url]
Now, let's say there is this content of {Q1}
[{ "title":"Title 1","comment":"Comment 1","size":11.111,"name":"name1.PNG","filename":"fu_12345678","ext":"png" }, { "title":"Title 2","comment":"Comment 2","size":22.222,"name":"name2.PNG","filename":"fu_22345678","ext":"png" }, { "title":"Title 3","comment":"Comment 3","size":33.333,"name":"name3.PNG","filename":"fu_32345678","ext":"png" }]
you get the title of the first file by:
{trim(substr(Q0, strpos(Q0,"title")+8,(strpos(Q0,"comment")-3-(strpos(Q0,"title")+
)))}
To get the title of the second file you have to make sure that "strpos" starts after the first "title". Here the offset appears.
To cover all desired values (title, comment, name) it is suitable to start the search for the second file at the end of the first.
And as all these strings have different lengths you can't use a fixed value for offset.
Therefore I used the position of "ext". So the offset is 'strpos(Q0,"ext")'.
And the equation to get the second title:
{trim(substr(Q0, strpos(Q0,"title", strpos(Q0,"ext"))+8,(strpos(Q0,"comment", strpos(Q0,"ext"))-3-(strpos(Q0,"title", strpos(Q0,"ext"))+
)))}
Now it becomes easy. To get the title of the third file, we create the position of the second "ext" as offset.
How?
You get this position when you search for "ext" with an offset greater than the position of the first "ext", like
strpos(Q0,"ext",strpos(Q0,"ext")+5)
Find the position of "ext", but start five characters after the position of the first "ext".
{trim(substr(Q0, strpos(Q0,"title", strpos(Q0,"ext", strpos(Q0,"ext")+5))+8,(strpos(Q0,"comment", strpos(Q0,"ext", strpos(Q0,"ext")+5))-3-(strpos(Q0,"title", strpos(Q0,"ext", strpos(Q0,"ext")+5))+
)))}
The next analogue.
I said before it is straightforward, but lengthy.
Therefore I showed the other solution where you split the string first
Joffm