fork(4) download
  1. <?php
  2. $urls = ['imports', 'var', 'js'];
  3. $url_pattern = '/example.com\/(' . implode('|', $urls) . ')\/.*/';
  4.  
  5. $remove_urls = [
  6. "example.com/imports/product.html",
  7. "example.com/imports/product1.html",
  8. "example.com/var/cache/5t46fdgdyg7644gfgfdgr",
  9. "example.com/css/style.css",
  10. "example.com/js/scripts.js"
  11. ];
  12.  
  13. $removed = preg_grep($url_pattern, $remove_urls);
  14. print_r($removed);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => example.com/imports/product.html
    [1] => example.com/imports/product1.html
    [2] => example.com/var/cache/5t46fdgdyg7644gfgfdgr
    [4] => example.com/js/scripts.js
)