Write a PHP program to find the first non-repeated character in a given string
- برمجة بي اتش بي
- 2021-09-08
- mhanasmh00489829403
الأجوبة
<?php
function find_non_repeat($word) {
$chr = null;
for ($i = 0; $i <= strlen($word); $i++) {
if (substr_count($word, substr($word, $i, 1)) == 1) {
return substr($word, $i, 1);
}
}
}
echo find_non_repeat("Green")."\n";
echo find_non_repeat("abcdea")."\n";
?>
Sample Output:
G b
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال