How to compare the length of two strings in php, length of two strings in php_PHP tutorial

WBOY
Release: 2016-07-13 09:46:34
Original
907 people have browsed it

How to compare the length of two strings in php, the length of two strings in php

The example in this article describes the method of comparing the length of two strings in php. Share it with everyone for your reference. The specific implementation method is as follows:

This code calculates the length of two strings and then calculates their difference

<&#63;php 
// This will return a number of how many more characters the longest string has 
function str_compare_length($str1, $str2){ 
  $len1 = strlen($str1); 
  $len2 = strlen($str2); 
  return abs($len1 - $len2); 
} 
echo str_compare_length("This is the first string", "This is the second string"); 
&#63;>

Copy after login

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1031483.htmlTechArticleHow to compare the length of two strings in php, the length of two strings in php. This example describes how to compare two strings in php String length method. Share it with everyone for your reference. The specific implementation methods are as follows...
Related labels:
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