Giter VIP home page Giter VIP logo

reallysimplearraytest's Introduction

Really Simple Array Test

StyleCI

A simple array test for PHP developers. There are numerous ways to complete the tasks involved in this test and there are no right, or perfect, answers. The test though will reveal roughly how knowledgeable and experienced a developer is.

The Test

This test aims to see how well a developer understands arrays and array manipulation.

It is based around a small assocaitive array of users, the array item fields include forename, surname, username, email, age, country, city and created_at. Each task aims to test a different means of manipulating an array.

The User Array

[
    [
        'forename' => 'John',
        'surname' => 'Galt',
        'username' => 'jGalt95',
        'email' => '[email protected]',
        'age' => 22,
        'country' => 'USA',
        'city' => 'New York',
        'created_at' => '2016/04/02 16:53:22'
    ],
    [
        'forename' => 'Anne',
        'surname' => 'Jones',
        'username' => 'AnneJn',
        'email' => '[email protected]',
        'age' => 34,
        'country' => 'UK',
        'city' => 'Manchester',
        'created_at' => '2014/09/13 22:02:31'
    ],
    [
        'forename' => 'Craig',
        'surname' => 'Rodriguez',
        'username' => 'Rod4567',
        'email' => '[email protected]',
        'age' => 19,
        'country' => 'USA',
        'city' => 'Houston',
        'created_at' => '2017/01/29 06:12:59'
    ],
    [
        'forename' => 'Gary',
        'surname' => 'Smith',
        'username' => 'smithy12',
        'email' => '[email protected]',
        'age' => 60,
        'country' => 'UK',
        'city' => 'London',
        'created_at' => '2013/11/07 12:11:47'
    ],
    [
        'forename' => 'Stephanie',
        'surname' => 'Lehman',
        'username' => 'stephL89',
        'email' => '[email protected]',
        'age' => 28,
        'country' => 'Germany',
        'city' => 'Munich',
        'created_at' => '2014/04/23 18:12:03'
    ]
];

Task One

Create a new array that only includes users under the age of 30.

The new array should look like this...

[
    [
        'forename' => 'John',
        'surname' => 'Galt',
        'username' => 'jGalt95',
        'email' => '[email protected]',
        'age' => 22,
        'country' => 'USA',
        'city' => 'New York',
        'created_at' => '2016/04/02 16:53:22'
    ],
    [
        'forename' => 'Craig',
        'surname' => 'Rodriguez',
        'username' => 'Rod4567',
        'email' => '[email protected]',
        'age' => 19,
        'country' => 'USA',
        'city' => 'Houston',
        'created_at' => '2017/01/29 06:12:59'
    ],
    [
        'forename' => 'Stephanie',
        'surname' => 'Lehman',
        'username' => 'stephL89',
        'email' => '[email protected]',
        'age' => 28,
        'country' => 'Germany',
        'city' => 'Munich',
        'created_at' => '2014/04/23 18:12:03'
    ]
];

Task Two

Create a new array that adds a new field called fullname to each array item. This field should combine the values of the forename and surname fields.

Each array item in the new array should have the following output...

[
    'forename' => 'Stephanie',
    'surname' => 'Lehman',
    'username' => 'stephL89',
    'email' => '[email protected]',
    'age' => 28,
    'country' => 'Germany',
    'city' => 'Munich',
    'created_at' => '2014/04/23 18:12:03',
    'fullname' => 'Stephanie Lehman'
]

Task Three

Create a new array where each array item has had the email field removed.

Each array item in the new array should have the following output...

[
    'forename' => 'Stephanie',
    'surname' => 'Lehman',
    'username' => 'stephL89',
    'age' => 28,
    'country' => 'Germany',
    'city' => 'Munich',
    'created_at' => '2014/04/23 18:12:03'
]

Testing

To run from the command line, type:

$ php ./public/index.php

To test in the browser, either start a php server:

$ cd ./public
$ php -S localhost:8000

And navigate to http://localhost:8000. See the PHP Docs for more information.

Alternatively, use an online PHP parser such as PHP Fiddle.

Submitting Answers

To submit answers to this test please clone this repo, create a new branch and push it back up once you have completed the tasks.

Author

Rob Waller

Twitter: @robdwaller

License

MIT

reallysimplearraytest's People

Contributors

robdwaller avatar

Watchers

Adam Lewis 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.