how string comparison is done in php?
i wan to copmpare two strings and result i want is the same letters in both strings?
any help plz
baig772
19
Web Application Architect
Recommended Answers
Jump to PostThe strcmp() function is binary safe and case-sensitive.
Example
<?php
echo strcmp("Hello world!","Hello world!");
?>The output of the code above will be:
0
Jump to Post$text1 = "Hello this is!!! my time"; $text2 = "ThiHs is unbelievables"; $r1 = str_split(preg_replace("/[^a-zA-z]/","",$text1)); //make array of alphabetical chars only $r2 = str_split(preg_replace("/[^a-zA-z]/","",$text2)); //ditto $hits =array_unique(array_intersect($r1,$r2)); //get an array of common chars sort($hits); //sort chars $hits = implode(", ",$hits); //create a comma delimited list of chars …
All 5 Replies
aashuboss
0
Newbie Poster

diafol
baig772
19
Web Application Architect

diafol
baig772
19
Web Application Architect
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.