Loading...
Preparing your coding drills
Comprehensive reference for 67 PHP methods across 10 categories.
array_map
Applies a callback function to each element of the arrays. Returns a new array with transformed values.
array_filter
Filters elements of an array using a callback function. Preserves original keys.
array_reduce
Iteratively reduces the array to a single value using a callback function.
array_merge
Merges one or more arrays. Numeric keys are renumbered, string keys are overwritten.
array_keys
Returns all the keys or a subset of keys from an array.
array_values
Returns all values from an array with numeric keys starting from 0.
array_unique
Removes duplicate values from an array. First occurrence of each value is kept.
array_column
Returns the values from a single column of an input array of arrays or objects.
array_combine
Creates an array by using one array for keys and another for its values.
array_slice
Extracts a slice of the array.
in_array
Checks if a value exists in an array.
array_search
Searches for a value and returns the corresponding key if found.
usort
Sorts an array by values using a user-defined comparison function.
array_chunk
Splits an array into chunks of specified size.
str_contains
Checks if a string contains a given substring. Case-sensitive.
str_starts_with
Checks if a string starts with a given substring.
str_ends_with
Checks if a string ends with a given substring.
explode
Splits a string by a separator and returns an array of parts.
implode
Joins array elements into a string with a separator.
trim
Strips whitespace (or other characters) from the beginning and end of a string.
sprintf
Returns a formatted string using printf-style format specifiers.
str_replace
Replaces all occurrences of search string with replacement string.
substr
Returns part of a string.
preg_match
Performs a regular expression match.
collect
Creates a new Laravel Collection instance. Provides fluent, convenient wrapper for working with arrays.
Collection::map
Iterates through the collection and passes each value to the given callback.
Collection::filter
Filters the collection using the given callback, keeping only items that pass the truth test.
Collection::reduce
Reduces the collection to a single value by iteratively combining elements.
Collection::pluck
Retrieves all of the values for a given key from the collection.
Collection::where
Filters the collection by a given key/value pair.
Collection::groupBy
Groups the collection items by a given key or callback.
Collection::sortBy
Sorts the collection by the given key or callback.
Collection::first
Returns the first element in the collection that passes a given truth test.
Collection::chunk
Breaks the collection into multiple smaller collections of a given size.
Collection::flatMap
Maps a function over items and flattens the result by one level.
Collection::unique
Returns all unique items in the collection.
Collection::pipe
Passes the collection to the given callback and returns the result.
Model::find
Finds a model by its primary key.
Model::where
Adds a where clause to the query.
Model::with
Eager loads relationships to prevent N+1 query problems.
Model::create
Creates a new model and persists it to the database.
Model::updateOrCreate
Finds a record matching attributes or creates a new one, then updates it.
Model::belongsTo
Defines an inverse one-to-many relationship.
Model::hasMany
Defines a one-to-many relationship.
Model::scope
Defines a local query scope for reusable query constraints.
Str::of
Creates a fluent string instance for chaining string operations.
Str::slug
Generates a URL-friendly "slug" from the given string.
Arr::get
Gets a value from a nested array using dot notation.
Arr::only
Returns only the specified key-value pairs from the array.
Arr::except
Returns all key-value pairs except the specified keys.
optional
Allows you to access properties or call methods on an object that might be null.
tap
Calls the given callback with the value then returns the value.
now
Creates a new Carbon instance for the current time.
Carbon::parse
Parses a string or DateTime into a Carbon instance.
Carbon::diffForHumans
Gets the difference in a human-readable format.
Carbon::format
Formats the date using PHP date format characters.
gettype
Returns the type of a variable as a string.
get_debug_type
Returns the resolved name of the type of a variable (PHP 8+).
instanceof
Checks if an object is an instance of a class or implements an interface.
json_encode
Encodes a value as a JSON string.
json_decode
Decodes a JSON string into a PHP value.
file_get_contents
Reads entire file into a string.
file_put_contents
Writes data to a file.
round
Rounds a float to specified precision.
number_format
Formats a number with grouped thousands and decimal places.
max
Returns the highest value from arguments or array.
min
Returns the lowest value from arguments or array.