Write a PHP script to remove all characters from a string except a-z A-Z 0-9 or " "

  • برمجة بي اتش بي

Write a PHP script to remove all characters from a string except a-z A-Z 0-9 or " ".

Sample string: abcde$ddfd @abcd )der]

الأجوبة

<?php
$string = 'abcde$ddfd @abcd )der]';
echo 'Old string : '.$string.'';
$newstr = preg_replace("/[^A-Za-z0-9 ]/", '', $string);
echo 'New string : '.$newstr."\n";
?>

Sample Output:

Old string : abcde$ddfd @abcd )der]                         
New string : abcdeddfd abcd der
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...