PHP code example of xp-lang / php-pattern-operator

1. Go to this page and download the library: Download xp-lang/php-pattern-operator 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/ */

    

xp-lang / php-pattern-operator example snippets


if ($greeting ~ '/^H[ea]llo/') {
  // Matches!
}

if ($matches= $greeting ~ '/^H[ea]llo/') {
  // Work with $matches
}

if (preg_match($greeting, '/^H[ea]llo/')) {
  // Matches!
}

if (preg_match($greeting, '/^H[ea]llo/', $matches)) {
  // Work with $matches
}