mardi 21 juin 2016

How to rewrite a string and get params by pattern in php

$string = '/start info@example.com';
$pattern = '/{command} {name}@{domain}';

get array params in php, Like the example below:

['command' => 'start', 'name' => 'info', 'domain' => 'example.com'] 

and

$string = '/start info@example.com';
$pattern = '/{command} {email}'; 
['command' => 'start', 'email' => 'info@example.com']

and

$string = '/start info@example.com';
$pattern = '{command} {email}';
['command' => '/start', 'email' => 'info@example.com']

please help. Thanks

Aucun commentaire:

Enregistrer un commentaire