Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Calculation\TextData; 4 5 use PhpOffice\PhpSpreadsheet\Calculation\Exception as CalcExp; 6 use PhpOffice\PhpSpreadsheet\Calculation\Functions; 7 use PhpOffice\PhpSpreadsheet\Shared\StringHelper; 8 9 class Search 10 { 11 /** 12 * FIND (case sensitive search). 13 * 14 * @param mixed $needle The string to look for 15 * @param mixed $haystack The string in which to look 16 * @param mixed $offset Integer offset within $haystack to start searching from 17 * 18 * @return int|string 19 */ 20 public static function sensitive($needle, $haystack, $offset = 1) 21 { 22 try { 23 $needle = Helpers::extractString($needle); 24 $haystack = Helpers::extractString($haystack); 25 $offset = Helpers::extractInt($offset, 1, 0, true); 26 } catch (CalcExp $e) { 27 return $e->getMessage(); 28 } 29 30 if (StringHelper::countCharacters($haystack) >= $offset) { 31 if (StringHelper::countCharacters($needle) === 0) { 32 return $offset; 33 } 34 35 $pos = mb_strpos($haystack, $needle, --$offset, 'UTF-8'); 36 if ($pos !== false) { 37 return ++$pos; 38 } 39 } 40 41 return Functions::VALUE(); 42 } 43 44 /** 45 * SEARCH (case insensitive search). 46 * 47 * @param mixed $needle The string to look for 48 * @param mixed $haystack The string in which to look 49 * @param mixed $offset Integer offset within $haystack to start searching from 50 * 51 * @return int|string 52 */ 53 public static function insensitive($needle, $haystack, $offset = 1) 54 { 55 try { 56 $needle = Helpers::extractString($needle); 57 $haystack = Helpers::extractString($haystack); 58 $offset = Helpers::extractInt($offset, 1, 0, true); 59 } catch (CalcExp $e) { 60 return $e->getMessage(); 61 } 62 63 if (StringHelper::countCharacters($haystack) >= $offset) { 64 if (StringHelper::countCharacters($needle) === 0) { 65 return $offset; 66 } 67 68 $pos = mb_stripos($haystack, $needle, --$offset, 'UTF-8'); 69 if ($pos !== false) { 70 return ++$pos; 71 } 72 } 73 74 return Functions::VALUE(); 75 } 76 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body