2

Not printing the expected result;

<?php
  mb_internal_encoding( 'UTF-8');
  $term="لاہوری";     
  $sel="لا";                 
  $sterm=mb_strrichr($term, $sel, true, 'utf-8');
  $prefix=mb_strrichr($term, $sel, false, 'utf-8');

  echo $sterm;
  echo "<br>";
  echo $prefix;
?>

Actual Result: لاہوری,

Expected Result: ہوری

Expected Result1: لا

halfer
  • 19,824
  • 17
  • 99
  • 186
Sugumar Venkatesan
  • 4,019
  • 8
  • 46
  • 77

2 Answers2

0

Here you have assigned "لاہوری" in $term and "لا" in $sel. This is stored in as "ی روہال" (without spaces) and "ال". So here echo $sterm; gives null as there is no characters from the beginning to the first occurrence of "ال" and echo $prefix; gives the output of characters from the first occurrence of "ال" to the end, that is "ی روہال"
(لاہوری)

Mûhámmàd Yäsår K
  • 1,492
  • 11
  • 24
-3
mb_internal_encoding( 'UTF-8');
                  $term="لاہوری";     
                  $sel="لا";                 

                  $prefix=str_replace('لا','',$term);

echo "Actual:".$term;
echo "<br>";
echo "Expected:".$prefix;
Balu
  • 23
  • 9