How to filter strings and just allow a-z and A-Z and /or numbers

This is how you can filter strings and just allow a-z and A-Z and /or numbers.

<?php
//Allow only a-z, A-Z and 0-9
         
if(ctype_alnum($value) > 0) {
           
$tags_array[] = $value;
          }

//Allow only a-z and A-Z
         
if(ctype_alpha($value) > 0) {
           
$tags_array[] = $value;
          }
?>

Read more about ctype_alnum() or ctype_alpha()

Knowledge keywords: