Reputation: 81
I have a form. I want when users fill the form with these content for example:
Word (in Spain)
or
Word2 (in England)
Automatically (in *) removed and saved in database like this:
Word1
or
Word2
I used this code:
$obj['String'] = trim(preg_replace( '(in /\(.*)\/)', '', $obj['String'] ));
but this code not working and my table in database filled blank.
Upvotes: 1
Views: 1295
Reputation: 91488
You aren't escaping the right characters, have a try with:
$obj['String'] = preg_replace( '/\s*\(in .*\)\s*$/', '', $obj['String'] );
Upvotes: 1