Home >Backend Development >PHP Problem >How to remove brackets in php

How to remove brackets in php

藏色散人
藏色散人Original
2021-03-16 09:58:222723browse

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.

How to remove brackets in php

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(&#39;(&#39;,&#39;&#39;,$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( &#39;(&#39;, &#39;)&#39; ), &#39;&#39;, $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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does php vc11 mean?Next article:What does php vc11 mean?