Fix: Reformatting Youtube Auto Generated Caption File

If you download auto-generated caption file from youtube and then use it in other platform like vimeo, you will see this auto-generated caption file doesn’t work. We can fix this by running a regular expression like this:

$caption_raw = file_get_contents($file_path);
$caption_formatted = preg_replace('/(<\d{2}:\d{2}:.*?(?:>)<c>)|(<\/c>)|(align:start position:\d+%)/', '', $caption_raw);
$over_written = file_put_contents($file_path, $caption_formatted);


PHP: Search for Files Inside Folder and Sub-Folder

To find all png files inside uploads directory we can use following code.
This would search in all sub-directories as well.

$Directory 	= new RecursiveDirectoryIterator('/wp-content/uploads/');
$Iterator 	= new RecursiveIteratorIterator($Directory);
$Regex 		= new RegexIterator($Iterator, '/^.+\.png$/i', RecursiveRegexIterator::GET_MATCH);	

foreach ($Regex as $file) {
	$file = $file[0];

MySQL: Import Table from CSV File

Run following command from command line

load data local infile "C:/Desktop/data.csv" into table tablename_here
fields terminated by ','
lines terminated by '\n' 
ignore 1 rows  
(col1, col2, col3....)

If your MariaDB doesn’t support this command, maybe you need to add following in my.ini file.


I am using Xampp on Windows 10. For me, my.ini file is located at: