$arr=[14,"id"=>134,[90,44,"name"=>["short"=>"Ambiorix","lastname"=>"Rodriguez"]]];
domingo, 12 de enero de 2025
viernes, 10 de enero de 2025
File functions grouped
1. File and Directory Manipulation
These functions are used to create, delete, move, or rename files and directories.
fopen()
— Opens a file or URL.fclose()
— Closes an open file.rename()
— Renames or moves a file or directory.unlink()
— Deletes a file.rmdir()
— Removes an empty directory.mkdir()
— Creates a new directory.opendir()
— Opens a directory.readdir()
— Reads an entry from an open directory.closedir()
— Closes an open directory.mkdir()
— Creates a new directory.file_put_contents()
— Writes data to a file (replaces the file if it already exists).file_get_contents()
— Reads a file into a string.
2. File and Directory Permissions
These functions are used for managing file and directory permissions (read/write/execute).
chmod()
— Changes the permissions of a file or directory.chown()
— Changes the owner of a file or directory.chgrp()
— Changes the group of a file or directory.fileperms()
— Returns the permissions of a file.umask()
— Sets the default file creation mask.
3. File and Directory Properties
These functions are used to retrieve information about files and directories.
file_exists()
— Checks if a file or directory exists.is_file()
— Checks if a given path is a regular file.is_dir()
— Checks if a given path is a directory.is_readable()
— Checks if a file or directory is readable.is_writable()
— Checks if a file or directory is writable.is_executable()
— Checks if a file or directory is executable.filemtime()
— Returns the last modified time of a file.fileatime()
— Returns the last access time of a file.filectime()
— Returns the inode change time of a file.filesize()
— Returns the size of a file.filetype()
— Returns the type of a file (e.g., regular file, directory).stat()
— Returns an array with file status information.fstat()
— Returns the status of an open file.dirname()
— Returns the directory name of a file path.basename()
— Returns the filename from a file path.pathinfo()
— Returns information about a file path.
4. File Reading and Writing
These functions are used to read from and write to files.
fread()
— Reads a file.fwrite()
— Writes to a file.fgets()
— Reads a line from a file.fgetcsv()
— Reads a CSV line from a file.file()
— Reads a file into an array.file_get_contents()
— Reads the entire content of a file into a string.file_put_contents()
— Writes data to a file.readfile()
— Reads a file and sends it directly to the output.fprintf()
— Writes formatted data to a file.
5. File Uploads
These functions are used for handling file uploads.
move_uploaded_file()
— Moves an uploaded file to a new location.is_uploaded_file()
— Checks if a file was uploaded via HTTP POST.$_FILES
— An array containing file upload information (used in conjunction with form file uploads).
6. Directory Traversal
These functions are used to traverse directories, list files, and iterate over directory contents.
opendir()
— Opens a directory for reading.readdir()
— Reads the next entry in an open directory.rewinddir()
— Resets the directory pointer to the beginning of a directory.closedir()
— Closes an open directory.scandir()
— Returns a list of files and directories in a directory.glob()
— Finds pathnames matching a pattern (e.g.,*.txt
).dir()
— Creates aDirectory
object for traversing directories (object-oriented approach).
7. File Locking
These functions are used for locking files to prevent other processes from modifying them.
flock()
— Acquires or releases a file lock.lockf()
— Locks or unlocks a file (using file descriptor).fnctl()
— Performs control operations on a file descriptor (Unix-based).
8. Temporary Files and Directories
These functions are used to create temporary files and directories.
tempnam()
— Creates a temporary file with a unique name.tmpfile()
— Creates a temporary file and returns a file handle.sys_get_temp_dir()
— Returns the system's temporary directory path.
9. File and Directory Traversal (Recursion)
These functions are used for recursively traversing directories and working with nested structures.
RecursiveDirectoryIterator
— Iterates over directories and subdirectories.RecursiveIteratorIterator
— Provides a recursive iterator for iterating through nested directories.DirectoryIterator
— Iterates over files and directories in a directory.
10. Compression and Archiving
These functions help with creating or extracting compressed files and archives.
gzopen()
— Opens a gzipped file for reading or writing.gzread()
— Reads from a gzipped file.gzwrite()
— Writes to a gzipped file.gzclose()
— Closes a gzipped file.zip_open()
— Opens a ZIP archive.zip_read()
— Reads a file from a ZIP archive.zip_close()
— Closes a ZIP archive.tar()
— Creates a TAR archive.
11. Miscellaneous Functions
Other miscellaneous filesystem-related functions:
disk_free_space()
— Returns the free space available on a disk or directory.disk_total_space()
— Returns the total space on a disk or directory.realpath()
— Returns the absolute path of a file or directory.clearstatcache()
— Clears the file status cache, used after modifying file information.file_exists()
— Checks if a file or directory exists.touch()
— Sets the access time and modification time of a file.
Datetime grouped
1. Date and Time Formatting
These functions are used to format dates and times.
date()
— Formats a local date and time according to a specified format.date_create()
— Creates a newDateTime
object.date_format()
— Formats aDateTime
object.strftime()
— Formats a local time/date according to the specified format (locale-dependent).gmdate()
— Formats a GMT date and time.time()
— Returns the current Unix timestamp (seconds since the Unix Epoch).getdate()
— Returns an associative array containing date information.localtime()
— Returns an associative array containing local time information.microtime()
— Returns the current Unix timestamp with microseconds.date_create_from_format()
— Creates aDateTime
object from a specific format.date_parse()
— Parses a date and time into an array.
2. Date and Time Parsing and Conversion
These functions are used to parse strings into date/time objects or to convert them into other formats.
strtotime()
— Parses an English textual datetime description into a Unix timestamp.date_parse_from_format()
— Parses a date/time string into an associative array based on a specific format.date_create_from_format()
— Creates aDateTime
object from a string using a specified format.getdate()
— Retrieves date information from a timestamp.
3. Time Zone Functions
These functions help manage and manipulate time zones.
date_default_timezone_set()
— Sets the default time zone for all date/time functions.date_default_timezone_get()
— Gets the default time zone.timezone_open()
— Opens aDateTimeZone
object.timezone_identifiers_list()
— Returns a list of all supported time zones.timezone_name_get()
— Gets the name of the time zone.timezone_offset_get()
— Gets the offset from UTC for a time zone.timezone_transitions_get()
— Returns an array of time zone transitions.
4. Date and Time Arithmetic
These functions are used to add or subtract time and calculate intervals.
strtotime()
— Parses a relative time string (e.g.,+1 day
,-1 week
) and returns a Unix timestamp.date_add()
— Adds a time interval to aDateTime
object.date_sub()
— Subtracts a time interval from aDateTime
object.diff()
— Returns the difference between twoDateTime
objects as aDateInterval
object.date_interval_create_from_date_string()
— Creates aDateInterval
object from a date string.date_modify()
— Modifies theDateTime
object by adding or subtracting time.
5. Time and Date Comparisons
These functions are used to compare date and time values.
date_diff()
— Calculates the difference between twoDateTime
objects.date_timestamp_get()
— Gets the Unix timestamp from aDateTime
object.date_timestamp_set()
— Sets the Unix timestamp for aDateTime
object.time()
— Returns the current Unix timestamp.
6. Date and Time Information
These functions are used to retrieve specific parts or elements of a date/time.
date("Y-m-d H:i:s")
— Formats the current date and time.gettimeofday()
— Returns current Unix timestamp along with microseconds.localtime()
— Returns an associative array containing local time information.gmdate()
— Formats a GMT date and time.getdate()
— Returns an array of date information.
7. Date and Time Validation
These functions are used to check the validity of a given date or time.
checkdate()
— Validates a Gregorian date (month, day, year).is_numeric()
— Checks if a value is a valid numeric value for timestamps.date_create_from_format()
— Parses a date string into aDateTime
object, useful for validation.
8. Date and Time Intervals
These functions deal with intervals between dates and creating intervals.
date_interval_create_from_date_string()
— Creates aDateInterval
object from a string (e.g.,P1Y2M10DT2H30M
).date_add()
— Adds aDateInterval
object to aDateTime
object.date_sub()
— Subtracts aDateInterval
object from aDateTime
object.date_diff()
— Calculates the difference between twoDateTime
objects.date_interval_format()
— Formats aDateInterval
object as a string.
9. Miscellaneous Functions
These functions provide additional utility when working with date and time.
time()
— Returns the current Unix timestamp.microtime()
— Returns the current Unix timestamp with microseconds.date_default_timezone_set()
— Sets the default time zone for all date/time functions.date_default_timezone_get()
— Gets the default time zone.strtotime()
— Converts an English textual datetime description into a Unix timestamp.
Mysql grouped functions
1. Database Connection Functions
These functions are used for connecting to MySQL databases.
mysqli_connect()
— Opens a new connection to the MySQL server (procedural).mysqli_connect_errno()
— Returns the error code from the last connection attempt.mysqli_connect_error()
— Returns a description of the last connection error.mysqli_select_db()
— Selects the database to use (procedural).mysqli_get_client_version()
— Returns the MySQL client version.mysqli_get_host_info()
— Returns the current MySQL host information.mysqli_get_proto_info()
— Returns the MySQL protocol version.
2. Query Execution Functions
These functions execute SQL queries and handle the results.
mysqli_query()
— Performs a query on the database (procedural).mysqli_multi_query()
— Performs multiple SQL queries at once (procedural).mysqli_query()
— Executes a single query (returns a result set ortrue
on success).mysqli_prepare()
— Prepares an SQL statement for execution (object-oriented).mysqli_stmt_prepare()
— Prepares a statement for execution (procedural).mysqli_stmt_execute()
— Executes a prepared statement (procedural).mysqli_stmt_bind_param()
— Binds parameters to a prepared statement (procedural).mysqli_stmt_get_result()
— Retrieves the result set from a prepared statement (procedural).
3. Fetching and Retrieving Results
These functions are used to fetch or retrieve data from query results.
mysqli_fetch_assoc()
— Fetches a result row as an associative array.mysqli_fetch_row()
— Fetches a result row as a numeric array.mysqli_fetch_object()
— Fetches a result row as an object.mysqli_fetch_all()
— Fetches all result rows as an array (available in MySQLi).mysqli_fetch_lengths()
— Returns the length of the fields in the result set.mysqli_num_rows()
— Returns the number of rows in the result set.mysqli_num_fields()
— Returns the number of fields in a result set.mysqli_fetch_field()
— Retrieves information about a field in the result set.mysqli_fetch_fields()
— Retrieves an array of field information.
4. Prepared Statement Functions
These functions work specifically with prepared statements, which are used to prevent SQL injection.
mysqli_prepare()
— Prepares a SQL statement for execution.mysqli_stmt_bind_param()
— Binds variables to a prepared statement as parameters.mysqli_stmt_bind_result()
— Binds variables to store results of a prepared statement.mysqli_stmt_execute()
— Executes a prepared statement.mysqli_stmt_fetch()
— Fetches the results of a prepared statement.mysqli_stmt_get_result()
— Retrieves the result set from a prepared statement.
5. Data Insertion, Update, and Deletion
These functions are used for manipulating data in MySQL.
mysqli_insert_id()
— Returns the auto-increment ID generated by the lastINSERT
query.mysqli_affected_rows()
— Returns the number of affected rows by the last query.mysqli_query()
— Executes anINSERT
,UPDATE
, orDELETE
query (returnstrue
on success).mysqli_commit()
— Commits the current transaction (used withmysqli_begin_transaction()
).mysqli_rollback()
— Rolls back the current transaction (used withmysqli_begin_transaction()
).mysqli_autocommit()
— Enables or disables autocommit mode.
6. Error Handling Functions
These functions are used for handling errors when working with MySQL.
mysqli_error()
— Returns the last error message for the most recent MySQL operation.mysqli_errno()
— Returns the error code for the most recent MySQL operation.mysqli_sqlstate()
— Returns the SQLSTATE error code for the most recent MySQL operation.mysqli_warning_count()
— Returns the number of warnings from the last query.
7. Transaction Management
These functions help manage database transactions.
mysqli_begin_transaction()
— Starts a transaction (MySQL 5.5 and higher).mysqli_commit()
— Commits the current transaction.mysqli_rollback()
— Rolls back the current transaction.mysqli_autocommit()
— Turns autocommit mode on or off.mysqli_set_charset()
— Sets the default character set for the connection.
8. Database and Table Management Functions
These functions are used to manage databases, tables, and other schema elements.
mysqli_select_db()
— Selects a database to work with.mysqli_create_db()
— Creates a new database.mysqli_drop_db()
— Drops an existing database.mysqli_query()
— Executes a query, likeCREATE TABLE
,DROP TABLE
, etc.mysqli_list_tables()
— Lists all tables in the selected database.mysqli_list_fields()
— Lists fields (columns) of a table.mysqli_show_tables()
— Shows the tables in the selected database.
9. Connection and Session Functions
These functions help manage the MySQL server connection.
mysqli_ping()
— Pings the server to check if the connection is still alive.mysqli_close()
— Closes the MySQL connection.mysqli_get_client_version()
— Returns the MySQL client version.mysqli_get_host_info()
— Returns information about the current host connection.mysqli_get_proto_info()
— Returns the protocol version used to communicate with MySQL.mysqli_get_server_version()
— Returns the MySQL server version.
10. Result Set and Field Functions
These functions are used to handle and manipulate the result set.
mysqli_free_result()
— Frees the memory associated with a result.mysqli_field_seek()
— Seeks to a specified field in a result set.mysqli_fetch_field()
— Retrieves a single field information from the result.mysqli_fetch_fields()
— Retrieves an array of field information.mysqli_data_seek()
— Seeks to a specified row in a result set.
11. MySQLi and PDO (Object-Oriented Functions)
Both MySQLi and PDO provide object-oriented approaches to working with MySQL databases.
MySQLi Object-Oriented
$mysqli->connect()
— Establishes a connection to the database.$mysqli->query()
— Executes a query on the database.$mysqli->prepare()
— Prepares an SQL statement for execution.$mysqli->bind_param()
— Binds variables to a prepared statement.$mysqli->execute()
— Executes a prepared statement.$mysqli->fetch_assoc()
— Fetches a result row as an associative array.
PDO (PHP Data Objects)
$pdo->connect()
— Establishes a connection to the database (via a DSN).$pdo->prepare()
— Prepares an SQL statement for execution.$pdo->execute()
— Executes a prepared statement.$pdo->fetch()
— Fetches the next row from a result set.$pdo->exec()
— Executes a query and returns the number of affected rows.
12. Miscellaneous Functions
These are additional functions related to MySQL operations.
mysqli_get_client_version()
— Returns the client version of MySQL.mysqli_get_server_version()
— Returns the server version of MySQL.mysqli_get_charset()
— Returns the current character set of the MySQL connection.
String functions grouped
1. String Manipulation Functions
These functions help you manipulate or transform strings.
str_replace()
— Replaces all occurrences of a substring within a string.substr()
— Returns a part of a string.substr_replace()
— Replaces part of a string with another string.str_split()
— Splits a string into an array of characters.explode()
— Splits a string into an array by a delimiter.implode()
— Joins elements of an array into a string.str_pad()
— Pads a string to a certain length with another string.str_repeat()
— Repeats a string a specified number of times.strtr()
— Translates characters in a string.strtoupper()
— Converts a string to uppercase.strtolower()
— Converts a string to lowercase.ucwords()
— Capitalizes the first letter of each word in a string.ucfirst()
— Capitalizes the first letter of the string.lcfirst()
— Converts the first letter of the string to lowercase.trim()
— Removes whitespace from the beginning and end of a string.ltrim()
— Removes whitespace or other characters from the left side of a string.rtrim()
— Removes whitespace or other characters from the right side of a string.str_ireplace()
— Case-insensitive version ofstr_replace()
.
2. String Searching and Matching
These functions allow you to search for patterns, substrings, or specific characters in a string.
strpos()
— Finds the position of the first occurrence of a substring.strrpos()
— Finds the position of the last occurrence of a substring.str_contains()
(PHP 8.0+) — Checks if a substring exists in a string (returnstrue
/false
).str_starts_with()
(PHP 8.0+) — Checks if a string starts with a given substring.str_ends_with()
(PHP 8.0+) — Checks if a string ends with a given substring.strstr()
— Finds the first occurrence of a substring and returns the rest of the string from that point.strrchr()
— Finds the last occurrence of a character in a string and returns the rest of the string.preg_match()
— Performs a regular expression match.preg_match_all()
— Performs a global regular expression match.preg_replace()
— Performs a regular expression search and replace.preg_split()
— Splits a string by a regular expression pattern.
3. String Encoding and Decoding
These functions are used for encoding and decoding strings, often for use in different character sets or formats.
base64_encode()
— Encodes data in base64.base64_decode()
— Decodes base64-encoded data.urlencode()
— Encodes a string for use in a URL.urldecode()
— Decodes a URL-encoded string.rawurlencode()
— Encodes a string for use in a URL, with a different encoding scheme.rawurldecode()
— Decodes a raw URL-encoded string.htmlentities()
— Converts special characters to HTML entities.htmlspecialchars()
— Converts special characters to HTML entities, but with fewer characters.html_entity_decode()
— Converts HTML entities back to their corresponding characters.utf8_encode()
— Encodes a string to UTF-8.utf8_decode()
— Decodes a UTF-8 string to ISO-8859-1.
4. String Length and Comparison
These functions help measure and compare string lengths, as well as compare two strings.
strlen()
— Returns the length of a string.mb_strlen()
— Returns the length of a string (multibyte-safe).strcmp()
— Compares two strings (case-sensitive).strcasecmp()
— Compares two strings (case-insensitive).strncmp()
— Compares the firstn
characters of two strings (case-sensitive).strncasecmp()
— Compares the firstn
characters of two strings (case-insensitive).strnatcmp()
— Compares two strings using a natural order algorithm.strnatcasecmp()
— Compares two strings using a natural order algorithm (case-insensitive).
5. String Positioning and Substring Extraction
These functions deal with finding or manipulating positions and substrings within a string.
strchr()
— Alias ofstrstr()
, finds the first occurrence of a character in a string.strrchr()
— Alias ofstrrpos()
, finds the last occurrence of a character in a string.strstr()
— Finds the first occurrence of a substring in a string.substr()
— Extracts a portion of a string.substr_count()
— Counts the number of occurrences of a substring in a string.substr_compare()
— Compares part of two strings.strpbrk()
— Searches a string for any of a set of characters.strspn()
— Returns the length of the initial segment of a string that consists entirely of characters contained in a given mask.
6. String Formatting
These functions allow you to format or manipulate strings for output.
sprintf()
— Returns a formatted string.printf()
— Outputs a formatted string.vsprintf()
— Returns a formatted string, similar tosprintf()
, but accepts an array as arguments.vprintf()
— Outputs a formatted string, similar toprintf()
, but accepts an array as arguments.number_format()
— Formats a number with grouped thousands.chr()
— Returns a character from a given ASCII code.ord()
— Returns the ASCII code of a character.pack()
— Packs data into a binary string.unpack()
— Unpacks data from a binary string.
7. String Case Conversion
These functions are for changing the case of strings.
strtoupper()
— Converts a string to uppercase.strtolower()
— Converts a string to lowercase.ucfirst()
— Capitalizes the first letter of a string.lcfirst()
— Converts the first letter of a string to lowercase.ucwords()
— Capitalizes the first letter of each word in a string.mb_convert_case()
— Converts the case of a string (multibyte-safe).str_ireplace()
— Case-insensitive version ofstr_replace()
.
8. String Trimming and Whitespace Handling
These functions are used for managing whitespace in strings.
trim()
— Removes whitespace (or other characters) from the beginning and end of a string.ltrim()
— Removes whitespace (or other characters) from the left side of a string.rtrim()
— Removes whitespace (or other characters) from the right side of a string.str_word_count()
— Counts the number of words in a string.preg_replace()
— Can be used to remove unwanted whitespace patterns with regular expressions.
9. String Conversion and Parsing
These functions help in converting strings from one format to another.
strval()
— Converts a variable to a string.intval()
— Converts a string to an integer.floatval()
— Converts a string to a float.parse_str()
— Parses a query string into variables.str_getcsv()
— Parses a CSV string into an array.
10. Regular Expression Functions
These functions are used for matching and manipulating strings with regular expressions.
preg_match()
— Performs a regular expression match.preg_match_all()
— Performs a global regular expression match.preg_replace()
— Performs a regular expression search and replace.preg_split()
— Splits a string by a regular expression pattern.preg_grep()
— Returns an array of elements matching a regular expression.preg_filter()
— Filters elements of an array using a regular expression.
11. Miscellaneous String Functions
These are some additional string-related functions that don’t fit in the other categories.
str_repeat()
— Repeats a string a specified number of times.str_shuffle()
— Randomly shuffles all characters in a string.str_rot13()
— Encodes a string using the ROT13 cipher.soundex()
— Returns the soundex key of a string (used for phonetic matching).metaphone()
— Returns the metaphone key of a string (used for phonetic matching).
Array functions grouped
1. Array Functions that Apply a Callback
These functions allow you to apply a callback function to each element of an array.
array_map()
— Applies a callback to each element of an array (creates a new array).array_walk()
— Applies a callback to each element of an array (modifies the array in place).array_walk_recursive()
— Applies a callback to each element of an array recursively.array_filter()
— Filters elements of an array using a callback function.array_reduce()
— Reduces an array to a single value using a callback function.array_flip()
— Exchanges all keys and values in an array.array_column()
— Returns the values from a single column of the input array.
2. Array Functions for Checking Existence
These functions are used to check if a specific element or key exists in an array.
array_key_exists()
— Checks if a specific key exists in the array.array_key_first()
— Returns the first key of an array.array_key_last()
— Returns the last key of an array.array_search()
— Searches for a value in an array and returns its key.in_array()
— Checks if a value exists in an array.array_contains()
(PHP 8.1 and later) — Checks if a value exists in an array.array_flip()
— Flips the array (keys become values and values become keys), so you can check if a value exists as a key.array_search()
— Searches for a value in an array and returns the corresponding key.array_is_list()
— Checks if the array is a list (numeric keys only).
3. Array Functions for Sorting and Ordering
These functions are used to sort or manipulate the order of elements in an array.
sort()
— Sorts an array in ascending order.rsort()
— Sorts an array in descending order.asort()
— Sorts an array in ascending order, maintaining key-value relations.arsort()
— Sorts an array in descending order, maintaining key-value relations.ksort()
— Sorts an array by key in ascending order.krsort()
— Sorts an array by key in descending order.natsort()
— Sorts an array using a natural order algorithm (numeric order).natcasesort()
— Sorts an array using a natural order algorithm, ignoring case.usort()
— Sorts an array by values using a user-defined comparison function.uksort()
— Sorts an array by keys using a user-defined comparison function.uasort()
— Sorts an array by values using a user-defined comparison function while maintaining key-value relations.
4. Array Functions for Modifying or Manipulating Arrays
These functions are used to modify arrays in various ways.
array_merge()
— Merges two or more arrays into one.array_merge_recursive()
— Merges arrays recursively.array_slice()
— Extracts a portion of an array.array_splice()
— Removes a portion of the array and optionally replaces it.array_replace()
— Replaces elements of an array with elements of another array.array_diff()
— Computes the difference of arrays.array_diff_assoc()
— Computes the difference of arrays including keys.array_intersect()
— Computes the intersection of arrays.array_intersect_assoc()
— Computes the intersection of arrays including keys.array_chunk()
— Splits an array into chunks.array_pad()
— Pads an array to a certain length with a value.array_fill()
— Fills an array with values.array_flip()
— Swaps all keys with values.array_reverse()
— Reverses an array.
5. Array Functions for Aggregation and Summarization
These functions help you summarize or aggregate data from arrays.
array_sum()
— Returns the sum of all values in an array.array_product()
— Returns the product of all values in an array.array_count_values()
— Counts all values in an array.array_unique()
— Removes duplicate values from an array.array_map()
— Applies a callback function to each element in an array (returns a new array).array_filter()
— Filters elements of an array using a callback function.array_reduce()
— Reduces an array to a single value using a callback function.
6. Array Functions for Key and Value Manipulation
These functions are used for working with keys and values in arrays.
array_keys()
— Returns all keys of an array.array_values()
— Returns all values of an array.array_flip()
— Exchanges keys and values.array_rand()
— Picks one or more random keys from an array.array_key_first()
— Returns the first key of an array.array_key_last()
— Returns the last key of an array.
7. Array Functions for Array Information and Properties
These functions are used for getting information about the array.
count()
— Counts the number of elements in an array.array_length()
— Returns the length of an array (similar tocount()
).array_is_list()
— Checks if the array is a list (numerically indexed).array_chunk()
— Splits an array into chunks.array_filter()
— Filters elements in the array based on a callback.array_flip()
— Flips keys and values in an array.
8. Array Functions for Recursive Operations
These functions work with arrays that may be multidimensional (nested arrays).
array_walk_recursive()
— Applies a callback function to each element of an array recursively.array_map()
— Can be used recursively if you apply it to multidimensional arrays (via callback).array_filter()
— Can be used with a recursive callback if the array is multidimensional.array_merge_recursive()
— Merges arrays recursively, handling multidimensional arrays.
9. Other Miscellaneous Array Functions
These functions don’t fit neatly into other categories but are useful for specific tasks.
array_diff_key()
— Computes the difference of arrays using keys.array_intersect_key()
— Computes the intersection of arrays using keys.array_multisort()
— Sorts multiple arrays or multidimensional arrays.array_walk()
— Applies a callback to each element of an array.array_rand()
— Picks one or more random elements from an array.array_flip()
— Swaps keys and values.array_replace()
— Replaces elements of an array with values from another array.
array filter using call back function
function test($var) {
$r=($var>14)?1:0;
return $r;
}
$array=[13,12,34];
print_r(array_filter($array, "test"));
Array ( [2] => 34 )