Home » Search results for 'php array'

How to Use the PHP empty() Function

Check if PHP Variable Empty

This easy tutorial will show you how to use the PHP empty() function to check whether a variable can be considered empty and show some code examples. What Is Empty? A variable is considered empty in PHP if its value equates to FALSE or the variable does not exist. This means that the following are considered empty: An empty string (“”) The number zero (0) In any form (0.0000) Including strings containing only a 0 character (“0”) Boolean FALSE NULL An undeclared variable Empty arrays The empty() function is different from the isset() function. The latter checks only whether … Read more

Categories PHP

Home » Search results for 'php array'

Merge Arrays in JavaScript with concat() and push() [Examples]

JavaScript Join Merge Concatenate Arrays

This tutorial will show you the correct ways to merge two or more arrays in JavaScript with the concat method – and provide a warning about how not to merge arrays. Merging/Joining Arrays in JavaScript with the concat()* Method The concat() method exists with one purpose – to merge arrays. concat() Method Syntax array.concat(ARRAYS) Note that: array is the first array of the arrays to be joined ARRAYS should be a comma-separated list of arrays to be added to the first array They will be joined in the order of appearance concat() returns a new array – … Read more

Home » Search results for 'php array'

How to Use the PHP ‘while’ Loop, With Examples

PHP while

This tutorial will teach you how to use the while statement to build loops in the PHP programming language and show some examples. The while loop is the most straightforward kind of loop in PHP. The code inside the loop will execute for as long as the while condition is true. Change the condition, and the loop will exit. while loops are a fundamental part of PHP (and loops are an essential part of computer programming in general) – so it’s good to know how they work and what they can be … Read more

Categories PHP

Home » Search results for 'php array'

How to Use the PHP ‘do while’ Loop, With Examples

PHP do while

This tutorial will teach you how to use the do while statement to build loops in the PHP programming language, and show some examples. The do while loop is one of the simplest types of loop in PHP. The code inside the loop will execute for as long as the do while condition is true. Change the condition, and the loop will exit. do while loops are a fundamental part of PHP (and loops are an essential part of computer programming in general) – so it’s good to get to know how they … Read more

Categories PHP

Home » Search results for 'php array'

How to Execute PHP from the Command Line (Bash/Shell)

Execute PHP from the Command Line/Bash

This article will quickly run through the ways PHP can be used from the Bash shell/command line, with examples. PHP is usually used for generating content to be served on the web – but it can also be used from the command line. This is usually done for the purposes of testing or finding out information about the PHP environment – but PHP can also be used for writing command-line scripts (though, again, it’s not really done that frequently – probably because there are better … Read more

Home » Search results for 'php array'

How to Remove Duplicates From an Array in JavaScript [Examples]

Javascript Remove Duplicates from Array

Being able to remove duplicates from (or de-duplicate) an array is a useful thing to be able to do. Here’s how it’s done. What is an Array? In programming, an array is a type of variable that can hold other values, or references to other variables, in a list at a certain position. Arrays are vital to building any application – allowing you to store a list of variables or values of any length in a single variable – ready to be iterated over, processed, … Read more

Home » Search results for 'php array'

Using PHP cURL To Retrieve Data or Talk to an API

PHP cURL

The PHP cURL library adds support for requesting and submitting data over HTTP connections. This article will show you how to use it. There are a plethora of useful online services you can pull data from. From mapping to currency conversion, weather, flight schedules, language translations (in fact, just look at a big list of them here), these services, called APIs (Application Programming Interface), allow you to interact with massive databases of information over the HTTP protocol. PHP includes the tools to do this in its … Read more

Categories PHP

Home » Search results for 'php array'

Using PHP unset Function to Destroy a Variable, With Examples

PHP unset()

Here’s a short article on a useful PHP feature – the unset construct allows you to destroy a variable, making it unavailable for use. There are a few reasons why you might want to unset a variable: Making sure you don’t accidentally use a variable you don’t want to use in a certain context or scope Cleaning up variables after a loop Make a global variable unavailable within a function or scope Remove an element from an Array Remove an object attribute Read on to see how it’s done. … Read more

Categories PHP

Home » Search results for 'php array'

How to Use if…else Conditional Statements in PHP [Examples]

PHP If...Else

Here’s a handy guide on using if/else/elseif conditional statements in PHP to execute code based on certain conditions. if/else statements are found in pretty much all programming languages. Computer programs need to perform actions based on a user selection, or the result of a calculation, or the value received from a sensor – and if/else statements are how this is programmed into the system. When building even the most basic programs, you’ll use them, so they’re worth getting to know. PHP Syntax There are several parts to an if … Read more

Categories PHP

Home » Search results for 'php array'

How to Use the PHP echo Statement, With Examples

PHP echo

This quick tutorial will show you how to use the PHP echo statement to print/display information on screen. A computer program isn’t much good if it doesn’t display some output to the user. The echo statement prints a simple string of text in PHP – usually to the web browser. Syntax echo is a simple statement with a simple purpose – and it has simple syntax: echo expressions Note that: expressions should be one or more strings containing the text or characters you want to display on screen If more than … Read more

Categories PHP