PHP

how to replace all special characters except underscore and period in php?

[et_pb_section admin_label=”section”]
[et_pb_row admin_label=”row”]
[et_pb_column type=”4_4″][et_pb_text admin_label=”Text”]

how to replace all special characters except underscore and period in PHP?

<?php 
            $string="a quick borown fox jump over the lazy dog & ( jkl/)-ov";
            echo $string = preg_replace('/[^a-zA-Z0-9_.]/', '-', strtolower($string));

?>

 [/et_pb_text][/et_pb_column]
[/et_pb_row]
[/et_pb_section]

Basant

View Comments

Recent Posts

Laravel Development Company in India | Custom Laravel Web Development Services

Laravel has become one of the most popular PHP frameworks because it enables developers to…

3 months ago

Git Commands Cheat Sheet: 15 Essential Git Commands Every Developer Must Know (Beginner to Advanced Guide)

Git Commands Cheat Sheet: 15 Essential Git Commands Every Developer Must Know Git is one…

7 months ago

How to make dependent dropdown of state and district using cakephp2 form?

Creating dependent dropdowns in CakePHP 2 involves using AJAX to dynamically load data into the…

2 years ago