How to remove brackets in php

藏色散人
Release: 2023-03-08 18:26:02
Original
2680 people have browsed it

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)';
Copy after login

I tried:

<?php echo str_replace(&#39;(&#39;,&#39;&#39;,$coords); ?>
Copy after login

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);
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template