Hallo!

I have the following issue:

$str = "apple[1] pear[3] tomato[4] some text [16]"; 

How do I can undo the numerals and the brackets (only together)? And to change them to empty space.
Like this : apple pear tomato some text
Regex will be used possibly?

    I could be wrong .. but try this..

    [edit]
    Note: This is flawd, it will work in your example but itsn't perfect, will flaw I will work on it in a bit unless someone else answers
    [/edit]

    $str = "apple[1] pear[3] tomato[4] some text [16]"; 
    
    echo preg_replace("/[+[0-9]+]/","",$str);
    

    This should work..

    It will remove ONLY IF it has [ + number + ]

    Good Luck, let me know if I messed up (i am only so/so @ regex).

      Thank you!

      The program worked great!

        Write a Reply...