$directory = 'images/';
$files = glob($directory . '*');
$sql = '';
foreach ($files as $file) {
if(is_dir($file)) {
continue;
}
$sql .= '("' . $file . '", 3),';
}
$sql = 'INSERT INTO `people`(`name`, `deptId`) VALUES ' . substr($sql, 0, -1);
echo $sql;
надеюсь смысл понятен. $str = 'некий текст[36465464]';
echo $str, PHP_EOL;
echo preg_replace('/\[\d+\]/', '', $str);
ideone.com/OOAxcK if ( $result->num_rows > 0 )
{
while($row = $result->fetch_assoc())
{
$myArray[] = $row;
}
echo json_encode($myArray);
}