Here I have tried to show how to use ternary operator to find out a number is even or odd .
Continue reading “Simple Tutorial of Using Ternary Operator to Find Even and Odd Numbers”Author: allaboutbasic
Displaying All Images from a Folder Using PHP
In this script, I demonstrate how to retrieve and display all JPG and PNG images from a specified folder using PHP. The code uses the glob function to fetch images with specific extensions and then displays the images using HTML.
How to Handle Dynamic Parameters in PHP: Working with Unknown Number of Function Arguments
By using func_get_args(), you can capture and handle any number of parameters passed to a function, making your PHP functions more flexible and versatile.
When to Use array_walk() and array_map() in PHP: Working with Individual Array Elements
array_walk() and array_map() both are used to work with the individual array element. array_walk() allows for operations to be performed on each element, but it does not return a new array. Instead, it operates directly on the original array and is typically used for side effects like printing, modifying elements in-place, or other operations where the result is not needed in a new array.
On the other hand, array_map() Returns a new array with modified values.
Exploring Nested Ternary Operations in PHP
This guide demonstrates how to use braces to properly nest ternary operators in PHP, ensuring correct evaluation and avoiding common errors with practical example.
In Line 7 and 11 you can see how the first braces are used between the ternary operators which makes the output different.
Continue reading “Exploring Nested Ternary Operations in PHP”Understanding Array Differentiation in PHP
Here I will try to show about how to find different elements between arrays using array_diff and array_diff_assoc functions in PHP. This will help you to understand array differentiation based on values and keys.
Continue reading “Understanding Array Differentiation in PHP”Exploring PHP Array Functions: array_intersect and array_intersect_assoc
Today I will try to explore the PHP functions array_intersect and array_intersect_assoc to find common elements in arrays based on values and keys with example.
CODE:
Continue reading “Exploring PHP Array Functions: array_intersect and array_intersect_assoc”Sorting Arrays by Keys in PHP: ksort() and krsort() with Examples
Discover how to sort associative arrays by their keys using the ksort() and krsort() functions in PHP. This guide provides practical examples to help you understand how these sorting functions work while preserving the array keys.
CODE:
Continue reading “Sorting Arrays by Keys in PHP: ksort() and krsort() with Examples”Learning Plugins Development: Part 3

Here i am trying to create a custom WordPress plugin that generates a shortcode [post_title_with_pagination] to display post titles with pagination. This step-by-step guide will help you set up the plugin and use it in your WordPress site effectively. Please check Learning Plugins Development: Part 1 to find out the steps.
Continue reading “Learning Plugins Development: Part 3”Sorting Arrays in PHP: rsort() and arsort() Functions Explained
This PHP script provides an example of how to use rsort() for reverse sorting and arsort() for reverse sorting while preserving the array keys.
<?php
echo "<pre>";
$reverseSort= array("a","d","e","b","c");
echo " <br> Main array <br>";
print_r($reverseSort);
rsort($reverseSort);
echo"<br>After rsort():<br>";
print_r($reverseSort);
$reverseSort1= array("a","d","e","b","c");
echo " <br> Main array <br>";
print_r($reverseSort1);
echo"<br>After rasort() which preserve keys :<br>";
arsort($reverseSort1);
print_r($reverseSort1);
echo "</pre>";
?>
OUTPUT
Main array
Array
(
[0] => a
[1] => d
[2] => e
[3] => b
[4] => c
)
After rsort():
Array
(
[0] => e
[1] => d
[2] => c
[3] => b
[4] => a
)
Main array
Array
(
[0] => a
[1] => d
[2] => e
[3] => b
[4] => c
)
After rasort() which preserve keys :
Array
(
[2] => e
[1] => d
[4] => c
[3] => b
[0] => a
)