Mostly web developers face the problem of sorting an array in PHP. So to save their time here I am sharing the solution with example. Feel free to join us and you are always welcome to share your thoughts that our readers may find helpful. There are 6 functions to sort an array in PHP – #1. sort() – Sort Array in Ascending Order Below example shows sorted array in ascending order <?php $name = array(‘sonia’,’monica’,’raj’,’yogita’); sort($name); print_r($name); ?> Output :- Array ( [0] => monica …
Category: php
Explore php tutorials, tips, and guides on PHPMyPassion. Learn best practices and stay updated with latest php trends.
How To Start A PHP Session ?
Session is a special technique to store information of a user across the multiple pages. To begin with a new session, simply we use the PHP session_start() function. It is must to start a session in the top of every page. Session variables are set with the PHP global variable $_SESSION. Below is the simple example to start a new session. <?php // Start the sessionsession_start(); ?> <!DOCTYPE html> <html> <body> <b> my website </b> </body> </html> Creation & Accessing Session Data :- You can create session using $_SESSION[] php function.…
What Is PHP Session?
Definition :- A session is use to store details of a user across multiple pages. Session is technique to recognized a user from single page to all pages in one application. How the php session works :- When you open a website on browser, its create a session variable to store your information’s until you close the application. Your system knows who you are. It knows the time when you start the application and when you close it. Mostly when someone login to a website, as per programming it create a…
Send Get / Post Data Using PHP CURL
In this tutorial, I am explaining How to send Get / Post PHP curl Request with Parameters . I am explaining 3 types of curl request with an example of S2S communication. #PHP Simple cUrl Request Without Parameter. You can use below code to send CURL request with parameter. <?php $AffPostbackUrl = ‘https://phpmypassion.com’; curl_request($AffPostbackUrl); function curl_request($url, array $options = array()) { $defaults = array( CURLOPT_POST => 0, CURLOPT_HEADER => 0, CURLOPT_URL => $url, CURLOPT_FRESH_CONNECT => 1, CURLOPT_RETURNTRANSFER => 0, CURLOPT_FORBID_REUSE => 1, CURLOPT_TIMEOUT => 4 ); $ch = curl_init(); curl_setopt_array($ch,…
How To Generate And Download A Dynamic Excel Sheet Using PHP ?
I have got lot of queries regarding to generate an excel sheet and download that on the system using PHP. So I thought to share the proper solution with an article. You can download an excel by using two process. either you can use function to download excel sheet or you can use PHP code on the same page to download a dynamic excel sheet. So here I am going to describe both the process. you can use according to your ease. #Process 1: Download an excel using PHP script…
How To Reverse A String In PHP ?
Commonly in interview we have been asked about reverse a string. So here I am going to share the solution for this type of question with my article. Image source : google images This is a basic question but most of the developers are stuck in it due to hesitation of interview. Interviewer only want to ask the main logic to reverse a string. He can either ask the function in php to reverse a string or also ask about procedural logic behind this. You can reverse a string using…
How To Remove Case Sensitiveness Issue From Post Link In WordPress?
Resolving Case Sensitivity Issues in WordPress Post Links When updating a post in WordPress, you may notice that the post link (permalink) is automatically converted to lowercase, even if it originally contained a mix of uppercase and lowercase letters. This article explains why this happens and provides a solution to preserve case sensitivity in post links. The Issue The case sensitivity issue arises due to the sanitize_title() function in WordPress, located in the wp-includes/formatting.php file. This function processes the post title to generate a URL-friendly slug, converting it to lowercase…
How To Create Random URL .txt File From Sitemap.xml In PHP ?
Here I am sharing a simple PHP script to generate number of txt file from Sitemap.xml. This is a simple PHP script I wrote quickly for myself to create number of .txt files according to length of sitemap.xml for my page. This script will help you If you want to generate random .txt file from the URL existed in sitemap.xml. Follow the steps to generate random URL .txt file : Step #1 : Generate & Download sitemap.xml for your website. There are number of websites where you can generate sitemap.xml…
Best Interview Questions And Answers For Experienced PHP Developer
Question #1: How to get the location of php.ini? You can get the location of php.ini by using <?php phpinfo(); ?> code. Question #2: How to POST Data using CURL in PHP? you can execute POST data by using CURL as below : $data = array(‘name’ => ‘Ross’, ‘php_master’ => true); $url = ‘http://domain.com/abc.php’; // You can POST a file by prefixing with an @ (for <input type=”file”> fields) $handle = curl_init($url); curl_setopt($handle, CURLOPT_POST, true); curl_setopt($handle, CURLOPT_POSTFIELDS, $data); curl_exec($handle); curl_close($handle); Question #3: How to get duplicate values from array? you can get…
How To Insert Records Using Stored Procedure in MySql with PHP ?
If you want to insert large records in a table so it is great to do that by using of Stored Procedure. There are number of benefits to insert record with the use of Stored Procedure Stored procedure cached on server so the speed is more fast. A Stored Procedures will be in one place so that there’s no confusion of having business rules spread over potentially disparate code files in the project. More secure because there is no direct access with tables in database. I am describing the process…
