PHP Preg-Replace more than one underscore

前端 未结 8 1374
难免孤独
难免孤独 2020-12-17 03:22

How do I, using preg_replace, replace more than one underscore with just one underscore?

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 04:16

    This will Accept Only Characters,numeric value or Special Character found it will replace with _
    ");
        PRINT_R($_REQUEST);
        $str=$_REQUEST[str];
        $str=preg_replace('/[^A-Za-z\-]/', '_', $str);
        echo strtolower(preg_replace('/_{2,}/','_',$str));
    }
    ?>
    

提交回复
热议问题