Home » Search results for 'php array'

How to Use Variable Variables in PHP, with Examples

PHP Variable Variables

Variable variables let you dynamically access variables by their name. Sound confusing? This article will explain PHP variable variables, and provide code examples. What is a variable? In computer programming, variables store a value, or reference to a value, for later use. Variables have names, and when you access a named variable, the value it contains can be read or updated. Declaring variables in PHP In PHP, a variable is declared when it is first used: Above, a variable named $myVariable is declared using the = (equals) operator, and assigned the … Read more

Categories PHP

Home » Search results for 'php array'

Hash Tables/Associative Arrays in JavaScript – How and Why?

JavaScript Hash Tables

JavaScript does not have a native object class called a “hash table” – but that doesn’t mean that the functionality of hash tables doesn’t exist in the language. Here’s how to use hash tables in JavaScript, with working example code. What is a Hash Table? Also known as hash maps, hash tables are a data structure which maps a list of keys to a list of corresponding values for each key. Any value in the table can be retrieved by accessing it through the associated key. … Read more

Home » Search results for 'php array'

Checking an Array Contains a Value in JavaScript [Examples]

JavaScript in array includes

This article will show you how to check if a value is in an array in the JavaScript programming language. Code examples to check whether an array includes a value are provided. Arrays in JavaScript Arrays are a type of variable that hold an ordered list of values. Each value in an array has a position within the array, called the index. The index can be used to access each value in the array. Indexes are integer values, which start counting from 0 (zero) for the first … Read more

Home » Search results for 'php array'

Deleting Files in PHP with unlink() [Examples]

PHP Delete File with unlink()

This article will show you how to delete a single file or multiple files in PHP using the unlink() function, and provide code examples. Once you have file uploads working in PHP, you may want to allow your users to delete files they no longer wish to keep. Read on to find out how. There is no PHP Function called ‘Delete’ To clear up any confusion, unlink() is the function for deleting files in PHP. There is no built in PHP function called delete(). If you’re looking to delete a directory in PHP, … Read more

Categories PHP

Home » Search results for 'php array'

Ultimate Guide to Uploading Multiple Files With PHP [Examples]

PHP Multiple File Uploads Ultimate Guide

This tutorial will explain how to upload one or multiple files from the web browser to the server using PHP. Code examples are included, including the code for limiting file size and type. Being able to have your users upload files to your app has become expected functionality in most web apps. Photos, filled out PDF forms, videos, recordings – any kind of file can be uploaded, and the process is relatively straight forward. PHP provides all of the required tools for file uploading and … Read more

Categories PHP

Home » Search results for 'php array'

Multidimensional/Nested Arrays in JavaScript [Guide]

Multidimensional/Nested Arrays in JavaScript

This guide aims to succinctly show you how multidimensional arrays can be created and used in the JavaScript programming language. What are Arrays? Arrays are a key component in any app kind of app you may wish to build – arrays allow you to store an ordered list of variables or values of any length in a single variable – ready to be iterated over, displayed, or otherwise processed. For example, an array could contain a list of contacts for an instant messaging application, or … Read more

Home » Search results for 'php array'

How to Convert an Object to an Array in JavaScript [Examples]

JavaScript Convert Object to Array

This article will show you the ways to convert an object to an array in JavaScript – quickly and easily. There are many ways to convert objects to arrays, but these (should) be the most straightforward methods. Converting Object to Array in JavaScript – Values Only If you only need the values from the object, the Object.values() method will extract them into an array: var myObject = { colour: ‘blue’, number: 43, name: ‘Fred’, enabled: true }; var values = Object.values(myObject); console.log(values); The above will return an array with … Read more

Home » Search results for 'php array'

PHP_SELF – What It Is, and Why It’s Too Dangerous to Use [WARNING]

PHP_SELF

This article outlines the PHP_SELF attribute of the $_SERVER system information variable and why you should never, ever use it. What is _$SERVER? Check out our full article on $_SERVER here – but in short, it’s a variable containing an array with information about your PHP environment – including server and request details that are quite sensitive and shouldn’t be publicly accessible. What is $_SERVER[‘PHP_SELF’] ? $_SERVER[‘PHP_SELF’] contains the full path to the PHP script being executed, including any query parameters. This allows the party making the request to include arbitrary data. Displaying data … Read more

Categories PHP

Home » Search results for 'php array'

What is the $_SERVER Superglobal Variable in PHP?

PHP _SERVER

This article will explain what the $_SERVER superglobal variable is in the PHP programming language. What is a ‘Superglobal’ Variable? A superglobal variable is a variable that is available to all scripts in all scopes in PHP. It is available from within any file, class, or function. What is the $_SERVER Superglobal Variable? The $_SERVER superglobal contains information about the server and execution environment PHP is running in/on. It contains information on the request made to the web server, file paths, and other information. It will provide little to no info … Read more

Categories PHP

Home » Search results for 'php array'

A Trick for Validating JSON in PHP

PHP Validate JSON

Here’s a quick trick for validating JSON in PHP – with a reusable function, you can copy and paste it into your own project. JSON has pretty much become the standard format for transferring data between applications on the internet. So if you’re building an API to be consumed by others or just building a backend for your app, you’ll be sending and receiving a lot of JSON data. But, you can never trust the request – the data coming into your application. Users enter bad data. Hackers deliberately enter bad … Read more

Categories PHP