Welcome To Snipplr


Everyone's Recent PHP Snippets Tagged array



« Prev 1 2 3 4 5 6 7
  1. FAV

    PHP Random Spin

    A quick snippet to rotate a series of words on page load using PHP.
    PHP 121 views posted 4 months ago by danparks
  2. FAV

    Lister tous fichiers contenus dans un dossier

    php list all files of a given directory
    PHP 8 views posted 6 months ago by martinbrait
  3. FAV

    Convert XML to Array in PHP

    Convert easily XML File or String to Associative Array in PHP
    PHP 15 views posted 4 years ago by kavikms
  4. FAV

    Sort & query multi-dimensional arrays by properties

    Sort & query arrays in PHP. Sort multi dimensional arrays by object properties and filter the array by specific criteria. Documentation: https://github.com/mattnicholson/DataList
    PHP saved by 4 people 11 views posted 5 years ago by mattnicholson
  5. FAV

    Remove duplicates from multi-dimensional array 2

    Works with any array
    PHP 10 views posted 5 years ago by a1ias
  6. FAV

    array_map usage

    shows how to use array_map to mine data from nested arrays.
    PHP 11 views posted 5 years ago by ryantxr
  7. FAV

    Read and write data to textfile

    I created this code for practice, and I looking for better and clear solution for the last instance where I can write or delete the data, but after I want to get back the content as array or the key as string. I want to use this write-read back with...
    PHP 15 views posted 5 years ago by gitarfogas
  8. FAV

    Creating a nested array from items with parent IDs

    Creating a nested array from items with parent IDs. This is useful for when you have a website working with multiple categories with parent categories. But it can be applied anywhere, really!
    PHP 13 views posted 6 years ago by CreativePunch
  9. FAV

    Recursive multidimensional array traversing

    Traverses a multidimensional array and returns an array with the results. It also echoes the result as a string just for demonstration.
    PHP 7 views posted 6 years ago by gummiost
  10. FAV

    in_array_r($needle, $haystack, $strict = true);

    Search recursive in array
    PHP saved by 1 person 6 views posted 6 years ago by bigmichiel
  11. FAV

    Lambda function to create XML from Array

    This snippet is a lambda function (anonymous function) to create an xml from an array. It uses recursiveness.
    PHP saved by 3 people 7 views posted 6 years ago by abrahamsustaita
  12. FAV

    Language Codes ISO 2 letter (ISO 639-1) & 3 letter (ISO 639-2) with names in PHP array

    This table is based on the ISO 2 letter (Alpha-2 code, ISO 639-1) and 3 letter (Alpha-3 code, ISO 639-2) Standard Codes for the Representation of Names of Languages.
    PHP 15 views posted 6 years ago by rwt
  13. FAV

    Check if arrays equal each other

    Checks if two given arrays equal each other as php doesn't have a built in function for this.
    PHP 9 views posted 7 years ago by MaxHudson
  14. FAV

    Outputs the content of any field in $GLOBALS['lv'] - multi-dimensional array

    Outputs the content of a multi-dimensional array in the $GLOBALS['lv']
    PHP 8 views posted 7 years ago by steho
  15. FAV

    PHP Search String in Array - Case Insensitive

    Use it similar to in_array function of PHP.
    PHP 14 views posted 7 years ago by kosinix
  16. FAV

    PHP Convert Single Dimensional Array to Two Dimensional

    Function to convert a one dimensional array to two dimensional with option to specify how many columns. Returns two dimensional array on success or false on fail.
    PHP 11 views posted 7 years ago by kosinix
  17. FAV

    Sum keyed elements of an array

    Sum all elements of a bidimensional or multi-dimensional array with an assigned key
    PHP 6 views posted 7 years ago by eortiz
  18. FAV

    Print large arrays in a nicely formatted list of expandable divs

    I use this primarily for debugging purposes. This simply takes an array and creates an expandable item that prints the array out in a \<pre\> wrapping, making it easy to read. Very basic snippet.
    PHP 8 views posted 7 years ago by ringo380
  19. FAV

    Recursive Array Key Search

    Search recursively some value in array with the key name
    PHP 8 views posted 7 years ago by MonsterDev
  20. FAV

    Using array_map() on multidimensional arrays

    Using array_map() on multidimensional arrays
    PHP 17 views posted 7 years ago by pruntrut
  21. FAV

    Sorting an multidimensional array

    The following shoud do it. pass the array, index is what element you want to sort on (in your case use 3). Then you can sort asc or desc, and weather you want to use natural sorting (the way a human would sort, 2 before 10) and lastly case sensitive...
    PHP 11 views posted 7 years ago by pruntrut
  22. FAV

    array sort field

    sort a multidimensional array by field
    PHP 8 views posted 7 years ago by akt
  23. FAV

    array sort field

    sort a multidimensional array by field
    PHP 5 views posted 7 years ago by akt
  24. FAV

    PHP - Sorting of a key on a multi-dimensional array

    A nice way to do sorting of a key on a multi-dimensional array - DavidG
    PHP 9 views posted 7 years ago by satie83
  25. FAV

    objectToArray Part 2

    If you want to use this in a class, change the last line to: ` return array_map(array($this, __FUNCTION__), $object ); `
    PHP 11 views posted 7 years ago by jgomez
  26. FAV

    PHP - Convert an object to an associative array

    Converts a php object to an associative array
    PHP saved by 3 people 31 views posted 7 years ago by satie83
  27. FAV

    Pass PHP array parameter to Javascript Function

    Writing an PHP array in a javascript file with json_encode.
    PHP 13 views posted 7 years ago by Narayon
  28. FAV

    Sort multidimensional array

    This sorts a multi-dimensional array by one of the values in the array. Sorts in Desc order (most recent date first).
    PHP 10 views posted 8 years ago by bitsculptor
  29. FAV

    Sort Multi-Dimensional Arrays

    Very helpful function for sorting multi-dimensional arrays
    PHP 7 views posted 8 years ago by chasecrawford
  30. FAV

    Ordenar array bidimensional por parametro

    Ordena Array Bidimensional Asociativo de acuerdo a parametro del array.
    PHP 5 views posted 8 years ago by serialk89
« Prev 1 2 3 4 5 6 7