Topic: Reformat title in config.php

Hi. I'm a bit rusty on php and xml, so forgive if this is a naive question.
I have built a dynamic gallery using config.php by copying the script provided elsewhere. The creation of the XML bit is below:

for ($i=0; $i<sizeof($gallery); $i++)
{
    echo '<image imageURL="images/'.$gallery[$i].'" thumbURL="images/'.$gallery[$i].'" linkURL="" linkTarget="">';
    echo '<title></title>';
    echo '<caption></caption>';
    echo '</image>';
}

To display the filename as title, I changed the second "echo" line to:

    echo '<title><![CDATA['.$gallery[$i].']]></title>';

This works fine, but now I want to change the title to use substrings of the filename. It contains the date and time of the image, like  "cap_file20150514095246.jpg", which I want to display as  "2015-05-14   09:52". I can handle this in normal php, but everything I try within the "echo" line refuses to work - i.e. no images are shown at all.

Cay you help with any hints how to do this?

Thanks

Re: Reformat title in config.php

You should be able to replace $gallery[$i] with another variable without any problem.

Try the following:

function format($input) {
    return substr($input, 8, 4) . '-' . substr($input, 12, 2) . '-' . substr($input, 14, 2) . ' ' . substr($input, 16, 2) . ':' . substr($input, 18, 2);
}
echo '<title><![CDATA[' . format($gallery[$i]) . ']]></title>';

I do not know if all your image filenames use exactly the same format so the function above may not be robust enough but it should give you an idea of what might work.

If you continue to experience difficulties, then please post the code that you are using that fails and I'll take a look and hopefully be able to determine the cause of your problem.