Search code examples
phpcodeignitercodeigniter-2

Variable inside get_filenames function using CodeIgniter and PHP


With the following code I am trying to get the file name inside MY_PIC folder and then to print it but is not possible.

$this->load->helper('file');
$uid = 10;  
$files = get_filenames('./MAINDIRECTORY/<? echo $uid; ?>/MY_PIC');
print_r($files);

The only way to get the filename is the following:

$this->load->helper('file');    
$files = get_filenames('./MAINDIRECTORY/10/MY_PIC');
print_r($files);

Does any other way that can I use the variable $uid?


Solution

  • What you want here is to concat a string with a variable :

    $uid = 10;
    $files = get_filenames('./MAINDIRECTORY/' . $uid . '/MY_PIC');
    

    Hope this help ;)