CoolAsCarlito
10-11-2012, 10:28 AM
My goal here is to take the value of the attachments field which looks like this:
["file1.jpg","file2.jpg","file3.jpg"
And then run the for loop over the items. Attachments should also have an array inside of it. One index being is_file and the other being file_name. For each of the items I want to check to see if the files do exist in my directory. If they do then I want the attachment to have a value of TRUE for the is_file and FALSE if it is not. And for the file_name I want it to obviously have the file name.
$attachments = json_decode($attachments, TRUE);
for ($x = 0; $x < count($attachments); $x++)
{
$file_name = $attachments[$x];
if ($this->functions_model->is_file('assets/downloads/'.$file_name, FALSE) === TRUE)
{
$message_data->attachments['is_file'] = TRUE;
}
else
{
$message_data->attachments['is_file'] = FALSE;
}
$message_data->attachments['file_name'] = $file_name;
}
["file1.jpg","file2.jpg","file3.jpg"
And then run the for loop over the items. Attachments should also have an array inside of it. One index being is_file and the other being file_name. For each of the items I want to check to see if the files do exist in my directory. If they do then I want the attachment to have a value of TRUE for the is_file and FALSE if it is not. And for the file_name I want it to obviously have the file name.
$attachments = json_decode($attachments, TRUE);
for ($x = 0; $x < count($attachments); $x++)
{
$file_name = $attachments[$x];
if ($this->functions_model->is_file('assets/downloads/'.$file_name, FALSE) === TRUE)
{
$message_data->attachments['is_file'] = TRUE;
}
else
{
$message_data->attachments['is_file'] = FALSE;
}
$message_data->attachments['file_name'] = $file_name;
}