i want echo only value name no all.
my array:
$file_list[] = array(
'name' => $CI->upload->file_name,
'file' => $CI->upload->upload_path.$CI->upload->file_name,
'size' => $CI->upload->file_size,
'ext' => $CI->upload->file_ext,
'image_type' => $imageVar->image_type,
'height' => $imageVar->height,
'width' => $imageVar->width
);
}
my foreach:
foreach($upload_data as $file) {
echo '<li><ul>';
foreach ($file as $item => $value) {
echo '<li>'.$item.': '.$value.'</li>';
}
echo '</ul></li>';
}
output now:
- name: Chrysanthemum19.jpg
file: D:/xampp/htdocs/Siran-mehdi/uploads/Chrysanthemum19.jpg
size: 858.78
ext: .jpg
image_type: jpeg
height: 768
width: 1024- name: Desert19.jpg
file: D:/xampp/htdocs/Siran-mehdi/uploads/Desert19.jpg
size: 826.11
ext: .jpg
image_type: jpeg
height: 768
width: 1024
i want this output:
Chrysanthemum19.jpg, Desert19.jpg
see you full class and Controller
class Multi_upload(libraries) CI_Controller
With respect
First you need to find the part of your loop that outputs the filename:
echo '<li>'.$item.': '.$value.'</li>';
You only want the value to be displayed when $item
is equal to 'name'. You can express that in code like this:
$file['name']
Then, eliminate all the parts of your code that do not contribute to the desired output. Your new code can look like this:
$output = array();
foreach($upload_data as $file) {
$output[] = $file['name'];
}
echo implode( ',' $output );