fork download
  1. <?php
  2.  
  3. $text = 'bla-bla-bla';
  4. $unused_image = [];
  5. $text = preg_replace_callback("#\w#is", function($match) use(&$unused_image){
  6. $unused_image[] = $match[0];
  7. return '';
  8. }, $text);
  9.  
  10. var_dump($text);
  11. print_r($unused_image);
Success #stdin #stdout 0.02s 24968KB
stdin
Standard input is empty
stdout
string(2) "--"
Array
(
    [0] => b
    [1] => l
    [2] => a
    [3] => b
    [4] => l
    [5] => a
    [6] => b
    [7] => l
    [8] => a
)