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”Category: Web Development & WordPress
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
)
PHP Array Sorting: Using sort() and asort() with Practical Examples
Discover the various methods for sorting arrays in PHP, including the use of sort() and asort(). This guide provides a detailed explanation on how to sort both indexed and associative arrays while ensuring keys are preserved when necessary.
Understanding Recursive Functions with and without Stepping in PHP
This PHP code demonstrates the use of recursive functions with two examples: a normal recursive function that increments a number until a specified condition is met, and a recursive function with stepping, which increments by a specified step value.
Continue reading “Understanding Recursive Functions with and without Stepping in PHP”Learning Plugins Development: Part 2
This WordPress plugin creates a shortcode [show_posts] that displays a list of the latest posts with their titles linked to the post pages. It fetches and lists up to 10 posts ordered by their ID in ascending order.

The output will be like this

Understanding PHP Array Functions: Merge, Slice, and Splice
Here I have tried to show various PHP array functions such as array_merge, array_slice, and array_splice. You can see how to merge two arrays, slice an array into parts, and splice arrays by removing and replacing elements.
CODE:
Continue reading “Understanding PHP Array Functions: Merge, Slice, and Splice”Learning Plugins Development: Part 1
Here I am going to create a very small plugins, mainly a shortcode which will be used in any page and post and that will show the message “My First Attempt of creating plugin”.
