-1

How to remove specific expression from an array

Remove the following element

$value['#434434*siva']

Output :

434434siva
Narendrasingh Sisodia
  • 19,948
  • 5
  • 40
  • 50
V.J.SIVA
  • 47
  • 1
  • 1
  • 6

2 Answers2

1

You can use preg_replace('/[^A-Za-z0-9\-]/', '', $string) to remove all the special characters

<?php
    function clean($string) 
    {
        return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
    }
?>

Then for array, you can do it like:

<?php
    foreach($value as $val)
        clean($val);
?>

Source: Remove all special characters from a string

Community
  • 1
  • 1
Suyog
  • 2,354
  • 1
  • 10
  • 26
0

preg_replace('/[^A-Za-z0-9]*/', '#434434*siva')

only digit and

CoreaJK
  • 1
  • 1