Home  >  Article  >  Backend Development  >  How to replace empty link in php

How to replace empty link in php

藏色散人
藏色散人Original
2021-09-14 11:04:281686browse

In PHP, you can use the str_replace function to replace the link with an empty link. The code is such as "str_replace("URL","",url);"; the function of this function is to replace some characters in the string with other characters. .

How to replace empty link in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How to replace the empty link in php?

It’s very simple. The code is as follows:

$u = str_replace("网址","",url);

The second one is the URL. If it is empty, don’t fill it in.

str_replace() Function replaces some characters in a string with other characters (case sensitive).

This function must follow the following rules:

If the searched string is an array, then it will return an array.

If the searched string is an array, then it will find and replace each element in the array.

If you need to search and replace the array at the same time, and the elements that need to be replaced are less than the number of found elements, then the excess elements will be replaced with empty strings

If the searched is an array, and the replacement is a string, then the replacement string will work on all found values.

Note: This function is case-sensitive. Please use the str_ireplace() function to perform a case-insensitive search.

Note: This function is binary safe.

Syntax

str_replace(find,replace,string,count)

Parameters

find Required. Specifies the value to look for.

replace Required. Specifies the value to replace the value in find.

string Required. Specifies the string to be searched for.

count Optional. Variable counting the number of substitutions.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to replace empty link 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