i want to fetch all the names of files from a folder/directory, create a json in php and call it in javascript. the final resulsts in javascript should be an array like this const alllabels = ['img/filename','img/filename','img/filename','img/filename']. so far I get the file names and I can create a JSON in PHP. but am having trouble manipulating the JSON in the javascript file. below is my code.
$data = array();
foreach(glob('img/*.*') as $filename){
    $name = $filename;
    $data[] = array($name);
}
echo json_encode($data);
my javascript function is as below
const labels = [];
function getlabels() {
    $.ajax({
        type: "POST",
        url: "get_labos.php",
        data: "",
        success: function (html) {
            var results = Json.parse(html);
            labels = results;
            return labels;
        }
    })
}
const alllabels = [getlabels()];
i need alllabels to be an array like this. ['img/filename','img/filename','img/filename','img/filename'].
 
    