
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
AmitDiwan has Published 10744 Articles

AmitDiwan
5K+ Views
The glob function can be used to get the images from a specific folder. Below is a sample code for the same −The path to the image folder is specified and all the files that have a .png extension are extracted. They are displayed with the help of the foreach ... Read More

AmitDiwan
396 Views
Use glob to find all files matching a pattern.function recursive_directory_removal($directory) { foreach(glob("{$directory}/*") as $file) { if(is_dir($file)) { recursive_directory_removal($file); } else { unlink($file); } } rmdir($directory); }On PHP version 5.3 and ... Read More

AmitDiwan
4K+ Views
There is no difference between die and exit, they are the same.The PHP Manual for exit states −"This language construct is equivalent to die()."The PHP Manual for die states −"This language construct is equivalent to exit()."However, there is a small difference, i.e the amount of time it takes for the ... Read More

AmitDiwan
1K+ Views
The array_filter function can be used to match a partial value in an array. A callback can be provided, that helps in deciding which elements would remain in the array and which would be removed.When the callback returns false, it means the given element needs to be removed. Below is ... Read More

AmitDiwan
883 Views
SOAP and REST APIs are the widely used APIs.Consider the presence of a PHP class named manage.php that helps in managing the entries in a database.class manage { private $entryId; function __construct($entryId) { $this->entryId = $entryId; } function deleteEntry() { //delete $this->entryId from database }}On the server, this ... Read More

AmitDiwan
3K+ Views
The return value of strtolower can be passed as the third argument to str_replace (where $string is present). The str_replace function is used to replace a set of characters/character with a different set of character/string.Example Live Demo$str = 'hello have a good day everyone'; echo str_replace(' ', '-', strtolower($str));OutputThis will produce ... Read More

AmitDiwan
292 Views
Yes, it can be done using the unlink function. It has been shown below −Another alternative that deletes the script irrespective of whether the exit function is called or not, has been shown below ^minus;class DeleteOnExit { function __destruct() { unlink(__FILE__); } } $delete_on_exit = new DeleteOnExit();

AmitDiwan
331 Views
Regular expression$directory = new RecursiveDirectoryIterator(__DIR__); $flattened = new RecursiveIteratorIterator($directory); // Make sure the path does not contain "/.Trash*" folders and ends eith a .php or .html file $files = new RegexIterator($flattened, '#^(?:[A-Z]:)?(?:/(?!\.Trash)[^/]+)+/[^/]+\.(?:php|html)$#Di'); foreach($files as $file) { echo $file . PHP_EOL; }Using filtersA base class holds the regex that ... Read More

AmitDiwan
1K+ Views
The date function can be used to return the string formatted based on the format specified by providing the integer timestamp or the current time if no timestamp is givenThe timestamp is optional and defaults to the value of time().Example Live Demoif(date('j', $timestamp) === '1') echo "It is the first ... Read More