This is the code that I've created;
$abs = preg_grep('/^\~\$/gmi', $files);
var_dump($abs);
$json = json_encode($files);
echo($json);
Could anybody explain why it's not catching the second item in the following variable?
["Renewal Fee Reminder.docx","~$newal Fee Reminder.docx"]
edit:
Fixed, code is as follows (although only checks the first character);
$files = file_list($templateDir, '.docx');
function sortLineStarters($var) {
return !($var[0] == '~');
}
$sortedFiles = array_filter($files, "sortLineStarters");
$json = json_encode($sortedFiles);
echo($json);