PHP Archives - CodexWorld https://www.codexworld.com/how-to-category/php/ Web & Mobile App Development Company Sun, 06 Jul 2025 18:54:48 +0000 en-US hourly 1 https://www.codexworld.com/wp-content/uploads/2020/04/favicon.ico PHP Archives - CodexWorld https://www.codexworld.com/how-to-category/php/ 32 32 91409221 How to check if a string contains specific words in PHP https://www.codexworld.com/how-to/check-if-a-string-contains-specific-words-in-php/ https://www.codexworld.com/how-to/check-if-a-string-contains-specific-words-in-php/#respond Mon, 23 Jun 2025 07:05:32 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=5803 There are multiple ways to check if a string contains any words from the given array using PHP. You can check one specific word or multiple words from an array. Use the PHP str_contains() function to determine if a string contains a specific word. If you want to check multiple words in a string, define words in an array.

The post How to check if a string contains specific words in PHP appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/check-if-a-string-contains-specific-words-in-php/feed/ 0 5803
How to convert timestamp to time ago format in PHP https://www.codexworld.com/how-to/convert-timestamp-to-time-ago-format-in-php/ https://www.codexworld.com/how-to/convert-timestamp-to-time-ago-format-in-php/#respond Tue, 18 Jun 2024 12:21:08 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=5648 Time Ago format is used to display time in human-readable format, such as 5 seconds ago, 2 minutes ago, 1 day ago, etc. Relative time format helps to avoid different time zone conversions. In this example code snippet, we will show you how to create Time Ago function to convert timestamp to time ago using PHP.

The post How to convert timestamp to time ago format in PHP appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/convert-timestamp-to-time-ago-format-in-php/feed/ 0 5648
How to JOIN Multiple Tables in DataTables Server-side Processing using PHP https://www.codexworld.com/how-to/join-multiple-tables-in-datatables-server-side-processing-using-php/ https://www.codexworld.com/how-to/join-multiple-tables-in-datatables-server-side-processing-using-php/#comments Sat, 09 Mar 2024 04:29:51 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=5573 DataTables server-side processing is used to fetch data from the database and list them in a tabular view. In most cases, the single database table is used in DataTables with server-side processing. The SSP class gives you the possibility to JOIN multiple tables with DataTables server-side processing. You can apply the LEFT or INNER JOIN clause to the SQL query in server-side processing.

The post How to JOIN Multiple Tables in DataTables Server-side Processing using PHP appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/join-multiple-tables-in-datatables-server-side-processing-using-php/feed/ 1 5573
How to get file content from URL in PHP https://www.codexworld.com/how-to/get-file-content-from-url-in-php/ https://www.codexworld.com/how-to/get-file-content-from-url-in-php/#respond Tue, 31 Oct 2023 05:57:37 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=5517 There are various options available to get the content from the URL in PHP. You can get the file content from a remote URL using PHP. PHP file_get_contents() function is the easiest way to parse the content from a web URL. To use the file_get_contents() function, the allow_url_fopen directive must be enabled in the PHP configuration file (php.ini).

The post How to get file content from URL in PHP appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/get-file-content-from-url-in-php/feed/ 0 5517
How to get Current DateTime by given a Timezone in PHP https://www.codexworld.com/how-to/get-current-datetime-by-given-a-timezone-in-php/ https://www.codexworld.com/how-to/get-current-datetime-by-given-a-timezone-in-php/#respond Mon, 02 Oct 2023 05:36:52 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=5493 In general, we use the date() function to get date and time in PHP. It returns the time based on the timezone set in the PHP server. You can get the DateTime from the timezone set as default on the PHP configuration. In this example code, we will show you how to get the current time by given a timezone in PHP. You can get and display the current Date and Time from a specific timezone using PHP.

The post How to get Current DateTime by given a Timezone in PHP appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/get-current-datetime-by-given-a-timezone-in-php/feed/ 0 5493
How to Save Output of a PHP File in an HTML File https://www.codexworld.com/how-to/save-output-of-a-php-file-in-an-html-file/ https://www.codexworld.com/how-to/save-output-of-a-php-file-in-an-html-file/#respond Wed, 30 Aug 2023 16:14:17 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=5460 Saving dynamic page content in a static HTML file functionality is used for many purposes, page caching system is one of them. In the caching system, the dynamic data is stored in an HTML file and displays the content from the HTML file to make the page load faster. In this example code snippet, we will show you how to save output of a PHP file in an HTML file and store dynamic page content in an HTML file using PHP.

The post How to Save Output of a PHP File in an HTML File appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/save-output-of-a-php-file-in-an-html-file/feed/ 0 5460
How to Encrypt and Decrypt String in PHP https://www.codexworld.com/how-to/encrypt-and-decrypt-string-in-php/ https://www.codexworld.com/how-to/encrypt-and-decrypt-string-in-php/#respond Fri, 19 May 2023 18:08:50 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=5355 String encryption functionality is used to make sensitive information safe in the web application. With the encryption feature, the original string is encrypted with Salt/Key and stored. Later the encrypted string is decrypted by the Salt/Key that is used at the time of encryption. The encryption and decryption algorithm can be implemented with a salt key using PHP.

The post How to Encrypt and Decrypt String in PHP appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/encrypt-and-decrypt-string-in-php/feed/ 0 5355
How to Create Default Profile Image Dynamically from First and Last Name in PHP https://www.codexworld.com/how-to/create-default-profile-image-dynamically-from-first-and-last-name-in-php/ https://www.codexworld.com/how-to/create-default-profile-image-dynamically-from-first-and-last-name-in-php/#respond Wed, 26 Oct 2022 08:07:37 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=5112 The default image is used as a profile picture when a user signs up on the website. This default image is displayed as a profile picture until the user changes their profile picture. Generally, the same image is used as a default profile picture for all users. If you want to separate the default image for each user, it needs to be changed dynamically. In this code snippet, we will show you how to create a default profile image dynamically from the first and last names in PHP.

The post How to Create Default Profile Image Dynamically from First and Last Name in PHP appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/create-default-profile-image-dynamically-from-first-and-last-name-in-php/feed/ 0 5112
How to Remove Duplicate Values from an Array in PHP https://www.codexworld.com/how-to/remove-duplicate-values-from-an-array-in-php/ https://www.codexworld.com/how-to/remove-duplicate-values-from-an-array-in-php/#respond Mon, 19 Sep 2022 12:20:14 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=5069 Use array_unique() function to remove duplicate values from an array in PHP. You can remove duplicate values with case/space insensitively from an array using PHP array_map() function. Remove space from all strings in an array using the trim callback method with the array_map() function. Convert array values to lowercase using the strtolower callback method with the array_map() function.

The post How to Remove Duplicate Values from an Array in PHP appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/remove-duplicate-values-from-an-array-in-php/feed/ 0 5069
How to Get Time Difference Between Two DateTimes in Minutes using PHP https://www.codexworld.com/how-to/get-time-difference-between-two-dates-in-minutes-using-php/ https://www.codexworld.com/how-to/get-time-difference-between-two-dates-in-minutes-using-php/#respond Sun, 10 Apr 2022 18:06:03 +0000 https://www.codexworld.com/?post_type=how-to-guides&p=4928 Use the diff() method of the DateTime class to create a DateInterval object that calculates the difference between two date/time objects in time using PHP. The PHP strtotime() function can be used to get the time difference between two dates (DateTimes) in minutes. example code snippet helps to you get the difference in minutes between two dates with PHP.

The post How to Get Time Difference Between Two DateTimes in Minutes using PHP appeared first on CodexWorld.

]]>
https://www.codexworld.com/how-to/get-time-difference-between-two-dates-in-minutes-using-php/feed/ 0 4928