PHP

PHP Menu

PHP

similar_text() Function - Definition, Syntax, Parameters, Examples

Definition

The similar_text() function calculates the similarity between two strings.

Syntax

similar_text(string1, string2, percent)

Parameters

Parameter Description
string1 Required. Specifies the first string to be compared.
string2 Required. Specifies the second string to be compared.
percent Optional. Specifies a variable name for storing the similarity in percent.

Example

<?php
$str1 = "Hello World"; $str2 = "Welcome World"; echo similar_text($str1, $str2); similar_text($str1, $str2, $percent); echo $percent;

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods