Jump to content

[SOLVED] Array Wildcard


iceblox

Recommended Posts

Yes, with regular expressions and preg_replace():

 

<?php
//$file contains file contents as a string

$find = array(
'~£[0-9]{1,2}\.[0-9]{2} upfront cash back\.~'
);
$replace = array(
'0'
);
$file = preg_replace($find, $replace, $file);
?>

 

Instead of searching for 95.00 it searches for 1-2 digits, a dot, and then 2 digits. To search for e.g. 1-3 digits before the dot, use {1,3} instead of {1,2} in the code.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.