Code Monkey home page Code Monkey logo

php-emoji's Introduction

Php array functions… with Emojis πŸ™‚

Do you know Php array functions? They are powerful, but sometimes tricky to handle… πŸ˜•

Here a cheat-sheet using Emoji, with some of my favorite tricks: Enjoy! πŸŽ‰

Cheat-sheet

array_chunk([🍎, 🍐, 🍊, πŸ‹, 🍌], 2);
[[🍎, 🍐], [🍊, πŸ‹], [🍌]]
array_chunk([🍎, 🍐, 🍊, πŸ‹, 🍌], 2, true);
[[🍎, 🍐], [2 => 🍊, 3 => πŸ‹], [4 => 🍌]]
array_column(
    [
        ['people' => πŸ˜€, 'fruit' => 🍎, 'animal' => 🐢],
        ['people' => 😎, 'fruit' => 🍐, 'animal' => 🐭],
        ['people' => πŸ₯Ά, 'fruit' => 🍊, 'animal' => 🐰],
        ['people' => 🀑, 'fruit' => πŸ‹, 'animal' => 🦊],
        ['people' => 🀠, 'fruit' => 🍌, 'animal' => 🐯],
    ],
    'fruit'
);
[🍎, 🍐, 🍊, πŸ‹, 🍌]
array_column(
    [
        ['people' => πŸ˜€, 'fruit' => 🍎, 'animal' => 🐢],
        ['people' => 😎, 'fruit' => 🍐, 'animal' => 🐭],
        ['people' => πŸ₯Ά, 'fruit' => 🍊, 'animal' => 🐰],
        ['people' => 🀑, 'fruit' => πŸ‹, 'animal' => 🦊],
        ['people' => 🀠, 'fruit' => 🍌, 'animal' => 🐯],
    ],
    'fruit',
    'people'
);
[πŸ˜€ => 🍎, 😎 => 🍐, πŸ₯Ά => 🍊, 🀑 => πŸ‹, 🀠 => 🍌]
array_combine(
    [πŸ˜€, 😎, πŸ₯Ά, 🀑, 🀠],
    [🍎, 🍐, 🍊, πŸ‹, 🍌]
);
[πŸ˜€ => 🍎, 😎 => 🍐, πŸ₯Ά => 🍊, 🀑 => πŸ‹, 🀠 => 🍌]
array_count_values([🍎, 🍎, 🍌, 🍌, 🍎]);
[🍎 => 3, 🍌 => 2]
array_diff(
    [🍎, 🍐, 🍊, πŸ‹, 🍌],
    [❌, 🍐], [❌, 🍊], [❌, πŸ‹]
);
[0 => 🍎, 4 => 🍌]
array_diff_key(
    [🐢 => 🍎, 🐭 => 🍐, 🐰 => 🍊, 🦊 => πŸ‹, 🐯 => 🍌],
    [🐢 => ❌, 🐭 => ❌], [🐰 => ❌]
);
[🦊 => πŸ‹, 🐯 => 🍌]
array_fill_keys([🍎, 🍐, 🍊, πŸ‹, 🍌], βœ…);
[🍎 => βœ…, 🍐 => βœ…, 🍊 => βœ…, πŸ‹ => βœ…, 🍌 => βœ…]
array_fill(2, 3, 🍌);
[2 => 🍌, 3 => 🍌, 4 => 🍌]
array_filter([🍎, 0, 🍐, false, 🍊, null, πŸ‹, '', 🍌]);
[0 => 🍎, 2 => 🍐, 4 => 🍊, 6 => πŸ‹, 8 => 🍌]
array_filter([🍎, 🍐, 🍎, πŸ‹, 🍌], fn($❓) => $❓ === 🍎);
[0 => 🍎, 2 => 🍎]
array_flip([🐢 => 🍎, 🐭 => 🍐, 🐰 => 🍎, 🦊 => πŸ‹, 🐯 => 🍌]);
[🍎 => 🐰, 🍐 => 🐭, πŸ‹ => 🦊, 🍌 => 🐯]
array_intersect(
    [🍎, 🍐, 🍊, πŸ‹, 🍌],
    [❌, 🍊, 🍐], [🍊, 🍌]
);
[2 => 🍊]
array_intersect_key(
    [🐢 => 🍎, 🐭 => 🍐, 🐰 => 🍊, 🦊 => πŸ‹, 🐯 => 🍌],
    [🐢 => ❌, 🦊 => βœ…], [🦊 => βœ…, 🐯 => ❌]
);
[🦊 => πŸ‹]
array_keys(
    [🐢 => 🍎, 🐭 => 🍐, 🐰 => 🍊, 🦊 => πŸ‹, 🐯 => 🍌]
);
[🐢, 🐭, 🐰, 🦊, 🐯]
array_map(
    fn($πŸ‘€, $🍽) => "$πŸ‘€ ❀️ $🍽",
    [πŸ˜€, 😎, πŸ₯Ά, 🀑],
    [🍎, 🍐, 🍊, πŸ‹, 🍌]
);
['πŸ˜€ ❀️ 🍎', '😎 ❀️ 🍐', 'πŸ₯Ά ❀️ 🍊', '🀑 ❀️ πŸ‹', ' ❀️ 🍌']
array_map(
    null,
    [πŸ˜€, 😎, πŸ₯Ά, 🀑, 🀠],
    [🍎, 🍐, 🍊, πŸ‹],
    [🐢, 🐭, 🐰, 🦊, 🐯]
);
[[πŸ˜€, 🍎, 🐢], [😎, 🍐, 🐭], [πŸ₯Ά, 🍊, 🐰], [🀑, πŸ‹, 🦊], [🀠, null, 🐯]]
array_merge(
    [🐢 => 🍎, 🐭 => 🍐, 🐰 => ❌],
    [🐰 => 🍊, 🦊 => ❌, 🐯 => 🍌],
    [🦊 => πŸ‹],
);
[🐢 => 🍎, 🐭 => 🍐, 🐰 => 🍊, 🦊 => πŸ‹, 🐯 => 🍌]
array_pad([🍎, 🍐], 5, 🍌);
[🍎, 🍐, 🍌, 🍌, 🍌]
array_reverse([🍎, 🍐, 🍊, πŸ‹, 🍌]);
[🍌, πŸ‹, 🍊, 🍐, 🍎]
array_reverse([🍎, 🍐, 🍊, πŸ‹, 🍌], true);
[4 => 🍌, 3 => πŸ‹, 2 => 🍊, 1 => 🍐, 0 => 🍎]
array_slice([🍎, 🍌, 🍌, 🍌, 🍎], 1, 3);
[🍌, 🍌, 🍌]
array_slice([🍎, 🍌, 🍌, 🍌, 🍎], 1, 3, true);
[1 => 🍌, 2 => 🍌, 3 => 🍌]
array_unique([🍎, 🍎, 🍌, 🍌, 🍎]);
[0 => 🍎, 2 => 🍌]
array_values(
    [🐢 => 🍎, 🐭 => 🍐, 🐰 => 🍊, 🦊 => πŸ‹, 🐯 => 🍌]
);
[🍎, 🍐, 🍊, πŸ‹, 🍌]

How To

Requires at least php 7.4.

php README.php > README.md

php-emoji's People

Contributors

b-viguier avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.