
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
181 Views
Yes, it is possible to combine filter_input() with AND/OR in PHP. This can be done by looping over the POST fields−$value = filter_input(INPUT_POST, 'field', FILTER_DEFAULT, is_array($_POST['field']) ? FILTER_REQUIRE_ARRAY : NULL);An equivalent for the same user for each loop has been shown below−$memory = array(); //looping through all posted values foreach($_POST ... Read More

AmitDiwan
213 Views
PHPStorm can be used to test PHP applications using the PHPUnit testing framework.The PHP interpreter needs to be configured in phpstorm.The Composer should be installed and initialized with respect to the current project.Below are the steps to configure PHPUnit testing −Download phpunit.phar (manually or using the composer) and save it ... Read More

AmitDiwan
498 Views
The OPCache can be temporarily disabled by adding the below code to the script−ini_set('opcache.enable', 0);This can be used to tell whether OPCache was the reason behind the script failing. Due to this, the user will not have to go through every extension and turn them on/off to see which extension ... Read More

AmitDiwan
591 Views
Beginning from PHP version 7, it has been made possible to create anonymous classes. Every object in PHP is associated with a class. The anonymous classes can be instantiated to create objects.Example Live DemoOutputDoes the instance belong to parent class? = bool(true)In the above code, a parent class (my_sample_class) has been ... Read More

AmitDiwan
895 Views
Below is the same code to set encoding for FPDI library−Add new fonts that have the correct alphabets.$pdf->AddFont('DejaVu', '', 'DejaVuSansCondensed.php'); $pdf->SetFont('DejaVu', '', 10, '', false);The following are three possible encodings that are possible.cp1250 (Central Europe) cp1251 (Cyrillic) cp1252 (Western Europe) cp1253 (Greek) cp1254 (Turkish) cp1255 (Hebrew) cp1257 (Baltic) cp1258 (Vietnamese) ... Read More

AmitDiwan
204 Views
Both get the union of arrays, but array_merge() overwrites duplicate non_numeric keys. Let us now see an example of the array+array−Example Live DemoOutputThis will produce the following output−array(8) { ["p"]=> string(3) "150" ["q"]=> string(3) "100" ["r"]=> string(3) "120" ["s"]=> string(3) "110" ["t"]=> ... Read More

AmitDiwan
3K+ Views
To return all dates between two dates, the code is as follows −Example Live DemoOutputThis will produce the following output−array(11) { [0]=> string(10) "10-11-2019" [1]=> string(10) "11-11-2019" [2]=> string(10) "12-11-2019" [3]=> string(10) "13-11-2019" [4]=> string(10) "14-11-2019" [5]=> string(10) "15-11-2019" ... Read More

AmitDiwan
3K+ Views
To reset keys of array elements using PHP, the code is as follows−Example Live DemoOutputThis will produce the following output−array(4) { ["p"]=> string(3) "150" ["q"]=> string(3) "100" ["r"]=> string(3) "120" ["s"]=> string(3) "110" } array(4) { [0]=> string(3) "150" [1]=> ... Read More

AmitDiwan
2K+ Views
To remove the first character of a string in PHP, the code is as follows−Example Live DemoOutputThis will produce the following output −Before removing the first character = Test After removing the first character = estExampleLet us now see another example Live DemoOutputThis will produce the following output−Before removing the first character ... Read More

AmitDiwan
266 Views
To remove an array element and re-index the array, the code is as follows−Example Live DemoOutputThis will produce the following output−Array with leading and trailing whitespaces... Value = John Value = Jacob Value = Tom Value = Tim Comma separated list... John , Jacob , Tom , Tim Updated Array... Value ... Read More