PHP code example of selvinortiz / flux
1. Go to this page and download the library: Download selvinortiz/flux 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/ */
selvinortiz / flux example snippets
use SelvinOrtiz\Utils\Flux\Flux;
use SelvinOrtiz\Utils\Flux\Helper;
// The subject string (URL)
$str = 'http://www.selvinortiz.com';
// Building the pattern (Fluently)
$flux = Flux::getInstance()
->startOfLine()
->find('http')
->maybe('s')
->then('://')
->maybe('www.')
->anythingBut('.')
->either('.co', '.com')
->ignoreCase()
->endOfLine();
// Output the Flux instance
Helper::dump( $flux );
// Output the fluently built pattern (@see /src/SelvinOrtiz/Utils/Flux/Helper)
Helper::msg( $flux ); // /^(http)(s)?(\:\/\/)(www\.)?([^\.]*)(.co|.com)$/i
// Inspect the results
Helper::msg( $str );
Helper::msg( $flux->match( $str ) ? 'matched' : 'unmatched' );
Helper::msg( $flux->replace( 'https://$5$6', $str ) );