Skip to main content
codingCourses
  • HTML
  • CSS
  • JavaScript
  • PHP
  • PHP Tutorial
  • PHP Strings
  • PHP Arrays
  • PHP URL
PHP
  • PHP Tutorial
  • echo vs. print
    Understanding echo and print Statement
  • include vs. require
    Differences and Usage
  • Superglobals
    Simple and Essential Usage Guide
  • Constants
    define() vs. const and Array Constants
  • isset() and empty()
    Concepts, Usage, and Key Differences
  • gettype()
    Get the Data Type of a Variable as a String
  • is_int()
    Check if Integer
  • is_float()
    Check if Float
  • is_numeric()
    Check if Numeric
  • is_string()
    Check if String
  • is_array()
    Check if Array
  • is_bool()
    Check if Boolean
  • is_object()
    Check if Object
  • is_resource()
    Check if Resource
  • is_null()
    Check if NULL
  • preg_replace()
    Replace Text Using Regexes
  • preg_match()
    Check if a String Matches a Regex
  • preg_match_all()
    Find All Matches of a Regex
  • preg_split()
    Split String Using Regexes
  • foreach Loop
    Iterating Over Arrays and Objects
  • Detecting Client Browser Info
    $_SERVER['HTTP_USER_AGENT']
  • Detecting Mobile Devices
    Working with Functions for Mobile Detection
  • Distinguishing Between iOS and Android
    Methods to Check if Running on iOS or Android
PHP Strings
  • String Reference
  • trim()
    Trim Whitespace
  • strpos()
    Find First Substring Index
  • mb_strpos()
    Multibyte-Safe Alternative to strpos()
  • stripos()
    Find First Substring Index (Case-Insensitive)
  • mb_stripos()
    Multibyte-Safe Alternative to stripos()
  • str_contains()
    Check if a String Contains a Substring
  • substr()
    Slice Strings by Position and Length
  • mb_substr()
    Multibyte-Safe Alternative to substr()
  • ctype_digit()
    Check if Only Numeric Character(s)
  • explode()
    Convert a String to an Array
  • str_split()
    Split String by Length
  • str_replace()
    Replace Text in a String
PHP Arrays
  • Array Reference
  • in_array()
    Check if a Value Exists in an Array
  • array_map()
    Ideal for mapping array data to new values
  • array_filter()
    Filter Elements with a Callback
  • array_reduce()
    Reducing an Array to a Single Value
  • array_key_exists()
    Check if a Key Exists in an Array
  • array_keys()
    Get a List of Array Keys
  • array_values()
    Get a List of Array Values
  • array_search()
    Searching for a Value in an Array
  • array_diff()
    Finding Array Differences by Value
  • array_diff_assoc()
    Comparing Array Differences by Key–Value
  • array_intersect()
    Finding Common Values Between Arrays
  • array_intersect_assoc()
    Find Common Elements by Key-Value
  • array_slice()
    Slicing an Array
  • array_shift()
    Remove the First Element from an Array
  • array_merge()
    Merging Arrays
  • array_pop()
    Remove the Last Element from an Array
  • array_unshift()
    Add Elements to the Start of an Array
  • array_push()
    Add Elements to the End of an Array
  • implode()
    Convert an Array to a String
PHP URL
  • PHP URL Reference
  • URL Encoding Functions
    Function Purpose & Features
  • urlencode()
    Encoding a URL Query Parameter Value
  • rawurlencode()
    Safely Encoding URI Components
  • http_build_query()
    Build Query Strings from Arrays or Objects
  • URL Decoding Functions
    Function Purpose & Features
  • urldecode()
    Decoding URLs Encoded with urlencode()
  • rawurldecode()
    Decoding URLs Encoded with rawurlencode()
  • parse_str()
    Parse URL Query Strings into Variables

PHP Array Reference

PHP Next

Learn about PHP arrays and how to work with them.

PHP Array Reference
in_array()
Check if a Value Exists in an Array
The in_array() function checks if a specific value exists in an array. It returns true if the value is found, or false otherwise.
array_map()
Ideal for mapping array data to new values
The array_map() function applies the given callback function to each element of an array and returns a new array. The original array remains unchanged.
array_filter()
Filter Elements with a Callback
The filter() function filters an array, keeping only the values that meet a specified condition. By providing a callback function, it returns a new array containing only the elements that satisfy the condition.
array_reduce()
Reducing an Array to a Single Value
The array_reduce() function iterates through an array using a callback function to repeatedly reduce it to a single value. The original array remains unchanged.
array_key_exists()
Check if a Key Exists in an Array
The array_key_exists() function checks if a specified key (or index) exists in an array. It returns true if the key is found, or false otherwise.
array_keys()
Get a List of Array Keys
The array_keys() function returns a new array containing only the keys (indexes) from the given array. You can either get all keys or selectively extract only the keys that match a specific value.
array_values()
Get a List of Array Values
The array_values() function returns a new array containing all the values from the given array. The returned array uses consecutive numeric indexes starting from 0, and the original keys are ignored.
array_search()
Searching for a Value in an Array
The array_search() function searches an array for a value. It returns the key (or index) of the first matching element if found, or false if the value is not present.
array_diff()
Finding Array Differences by Value
The array_diff() function finds the differences in array values between two or more arrays and returns a new array containing values that exist only in the first array.
array_diff_assoc()
Comparing Array Differences by Key–Value
The array_diff_assoc() function compares array differences based on key–value pairs and returns an associative array containing the elements from the first array that are not present in the other arrays.
array_intersect()
Finding Common Values Between Arrays
The array_intersect() function returns an array containing values from the base array that also exist in one or more other arrays.
array_intersect_assoc()
Find Common Elements by Key-Value
The array_intersect_assoc() function compares arrays based on key–value pairs and returns the elements from the first array that also exist in the other arrays.
array_slice()
Slicing an Array
The array_slice() function extracts a specified range of elements from an array and returns the result as a new array.
array_shift()
Remove the First Element from an Array
The array_shift() function removes the first element from an array and returns it. This operation decreases the array's length by one.
array_merge()
Merging Arrays
The array_merge() function merges one or more arrays in order to create a new array. The elements of each array are appended to the end of the previous array, and the function returns the merged array.
array_pop()
Remove the Last Element from an Array
The array_pop() function removes the last element from an array and returns it. This operation decreases the array length by one.
array_unshift()
Add Elements to the Start of an Array
The array_unshift() function prepends one or more elements to the beginning of an array—similar to inserting items at the front. This also increases the array's length.
array_push()
Add Elements to the End of an Array
The array_push() function adds one or more elements to the end of an array—essentially 'pushing' them onto it, like stacking items. This also increases the array's length.
implode()
Convert an Array to a String
The implode() function joins array elements into a string using a custom delimiter. This function returns a single string by joining each element of a given array with a specified delimiter.
PHP Next

codingCourses offers coding tutorials made for everyone.
All materials and examples are continuously reviewed to prevent errors; however, complete accuracy cannot be guaranteed.
Therefore, please carefully test and review all materials and examples to ensure they are free of errors, bugs, or vulnerabilities before relying on them.
They are available under the Creative Commons Attribution 4.0 International

Copyright © codingCourses. All Rights Reserved.