Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 表格上的preg_替换_Php_Preg Replace - Fatal编程技术网

Php 表格上的preg_替换

Php 表格上的preg_替换,php,preg-replace,Php,Preg Replace,下面是一个php表单。我想通过删除任何非数字字符来格式化该值。我认为pregreplace是最好的选择,但我不确定如何实施它 任何帮助都将不胜感激。代码如下 if(isset($_GET['price-max'])) { if($_GET['price-max'] >= 1) { $args['meta_query'][] = array( 'key' => 'pyre_price', 'value' =>

下面是一个php表单。我想通过删除任何非数字字符来格式化该值。我认为pregreplace是最好的选择,但我不确定如何实施它

任何帮助都将不胜感激。代码如下

if(isset($_GET['price-max'])) {
    if($_GET['price-max'] >= 1) {
        $args['meta_query'][] = array(
            'key' => 'pyre_price',
            'value' => $_GET['price-max'],
            'compare' => '<=',
            'type' => 'numeric'
        );
    }
}
if(设置($\u GET['price-max'])){
如果($_GET['price-max']>=1){
$args['meta_query'][]=数组(
'key'=>'pyre_price',
'value'=>$\u GET['price-max'],

“比较”=>“这应该可以做到

$value = preg_replace('/[^0-9]+/', '', $value);

将所有非0-9的字符替换为空字符串。有关该函数的文档,请参阅。您可能还需要查看。

解决方法如下:

$valuemax = $_GET['price-max'];

$valuemax = preg_replace('/[^0-9]+/', '', $valuemax);

if(isset($_GET['price-max'])) {

if($_GET['price-max'] >= 1) {

    $args['meta_query'][] = array(

        'key' => 'pyre_price',

        'value' => $valuemax,

        'compare' => '<=',

        'type' => 'numeric'

    );

}

}
$valuemax=$\u GET['price-max'];
$valuemax=preg_replace(“/[^0-9]+/”,“$valuemax”);
如果(isset($_GET['price-max'])){
如果($_GET['price-max']>=1){
$args['meta_query'][]=数组(
'key'=>'pyre_price',
“值”=>$valuemax,
'比较'=>'