php method to remove brackets: first create a PHP sample file; then declare a variable containing brackets; finally pass "str_replace(array( '(', ')' ), '', $coords); " method can remove the parentheses.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
Specific questions:
php - How to remove brackets from string in PHP?
I have the following string and want to use str_replace or preg_replace to remove the brackets, but not sure how. I have been able to remove the opening bracket using str_replace, but cannot remove the closing bracket.
This stings:
$coords = '(51.50972493425563, -0.1323877295303646)';
I tried:
<?php echo str_replace('(','',$coords); ?>
Remove the left bracket, but now I need preg_replace to remove both brackets.
How do i do this?
Recommended learning: "PHP Video Tutorial"
Implementation method:
Try:
str_replace(array( '(', ')' ), '', $coords);
The above is the detailed content of How to remove brackets in php. For more information, please follow other related articles on the PHP Chinese website!