
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
1K+ Views
The code inside the 'Model' and the 'Controller' needs to be changed to include code that is shown below −Inside the 'Controller'$header = $this->model_name->call_head(); foreach($header as $item) { $name = $item['name']; $array['name'] = $name; $array['data'] = $item['data']; $child_val = $this->model_name->call_child($name); foreach($child_val as $value) { ... Read More

AmitDiwan
424 Views
The json_decode function can be used as shown below −json_decode($json_string_that_needs_to_be_converted, true);The below lines of code can be used to convert JSONL to array format −$json_string = '["m@gmail.com", "p@gmail.com", "q@gmail.com"]'; $array_of_data=json_decode($json_string);An alternate is to use the below code, wherein the way json_string has been defined changes −Example$json_string = "[\"m@gmail.com\", \"p@gmail.com\", \"q@gmail.com\"]"; ... Read More

AmitDiwan
576 Views
The below code can be used to convert hex value into HSL value −function hex_To_Hsl($hex) { $hex_val = array($hex_val[0].$hex_val[1], $hex_val[2].$hex_val[3], $hex_val[4].$hex_val[5]); $rgb_val = array_map(function($part) { return hexdec($part) / 255; }, $hex_val); $max_val = max($rgb_val); $min_val = min($rgb_val); $l = ($max_val + ... Read More

AmitDiwan
108 Views
A quick way of doing this has been shown below −if (array_flip($set)[$value] !== null) { echo "something"; //take some action }To customize the number of keys, the function can be customized in the below manner −function array_keys_exists(array $keys, array $arr) { return !array_diff_key(array_flip($keys), $arr); }Read More

AmitDiwan
6K+ Views
Data can be sent through JSON or via normal POST. Following is an example showing data sent through JSON −var value_1 = 1; var value_2 = 2; var value_3 = 3; $.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "your_url_goes_here", data: { data_1: value_1, data_2: value_2, data_3: ... Read More

AmitDiwan
572 Views
String has a time zone, and there is usually no need to set a default time zone. But when it needs to be printed, the default time zone can be set explicitly. Below is the code to do the same −Default timezoneExample Live Demoecho date_default_timezone_get();OutputThis will produce the following output −UTCWhen ... Read More

AmitDiwan
778 Views
This is not possible. A href can’t be hidden from a link. But the files can be rewritten and the request URL can be changed to look like this − name.php/5001Other than this, a post request can be used in the below way − Go This will expose a ... Read More

AmitDiwan
1K+ Views
Method 1$arr_main_array = array('test_val' => 123, 'other-value' => 456, 'test_result' => 789); foreach($arr_main_array as $key => $value){ $exp_key = explode('-', $key); if($exp_key[0] == 'test'){ $arr_result[] = $value; } } if(isset($arr_result)){ print_r($arr_result); }Method 2A functional approach An array_filter_key type of function is taken, and ... Read More

AmitDiwan
5K+ Views
Images can be resized using ImageMagick or GD functions. If GD’s functions are used, the size of the image file is also reduced when raw digital camera images are sampled. We will see how GD can be used to resize an image in the below code.function image_resize($file_name, $width, $height, $crop=FALSE) ... Read More

AmitDiwan
3K+ Views
The array_multisort function can be used to sort a multidimensional array based on multiple keys −Example$my_list = array( array('ID' => 1, 'title' => 'data one', 'event_type' => 'one'), array('ID' => 2, 'title' => 'data two', 'event_type' => 'zero'), array('ID' => 3, 'title' => 'data three', 'event_type' => ... Read More