Answers for "count the same char string in php"

PHP
5

how to count string characters in php

<?php
$str1 = 'Hello world!';
echo strlen($str1); // Outputs: 12
Posted by: Guest on June-27-2021
0

php count matching words in two strings

$string1 = 'The dog and cat love each other';
$string2 = 'the dog pooped in the yard';
$arr1 = explode(" ",$string1 );
$arr2 = explode(" ",$string2 );
$result = array_intersect($arr1 , $arr2 ); //matched elements
$num = count($result); //number of matches
Posted by: Guest on October-12-2021

Browse Popular Code Answers by Language