PHP code example of aegisora / is-array-rule

1. Go to this page and download the library: Download aegisora/is-array-rule library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aegisora / is-array-rule example snippets


[]
['foo', 'bar']
['key' => 'value']

null
true
123
'string'
new stdClass()

use Aegisora\Rules\IsArrayRule;
use Aegisora\RuleContract\Models\Context;

$result = IsArrayRule::create()->validate(
    Context::create(['name' => 'John'])
);

if ($result->isValid()) {
    // value is array
} else {
    // value is not array
}

use Aegisora\Rules\IsArrayRule;
use Aegisora\RuleContract\Models\Context;

$result = IsArrayRule::create()->validate(
    Context::create('not-array')
);

if ($result->isValid()) {
    // will not happen
} else {
    // validation failed
}

IsArrayRule::create();

is_array($value)