PHP code example of s-mcdonald / functions

1. Go to this page and download the library: Download s-mcdonald/functions 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/ */

    

s-mcdonald / functions example snippets


use function SamMcDonald\Functions\random_bool;

random_bool() ? 'foo' : 'bar';

echo array_rand_bias($array);

$myarray = [
    'David',
    'Matthew',
     ...
    'George',
];

if (array_entry_exist($array, 'foo', 'bar')) {...}

// Which is a more convenient way of typing 
if (isset($array['foo']) && $array['foo'] === 'bar') {}

$randomValue = array_rand_pluck($array);

// Alternative
$randomValue = $array[array_rand($array, 1)];

$like_int = "55";

if(like_int($like_int)) {
    echo "Yes this is could certainly be cast to an int.", PHP_EOL;
}

echo slugify("My friends long weekend at Bernie's");