コード例 #1
0
 /**
  * Replaces values of an array.
  *
  * @param array     $array
  * @param           $value
  * @param           $replacement
  * @param bool|true $recursively
  * @param bool|true $caseSensitive
  *
  * @return array
  * @author Andreas Glaser
  */
 public static function replaceValue(array $array, $value, $replacement, $recursively = true, $caseSensitive = true)
 {
     foreach ($array as $k => $v) {
         if ($recursively && is_array($v)) {
             $array[$k] = self::replaceValue($array[$k], $value, $replacement, $recursively, $caseSensitive);
         } elseif (is_string($v) && StringHelper::is($v, $value, $caseSensitive)) {
             $array[$k] = $replacement;
         }
     }
     return $array;
 }
コード例 #2
0
 /**
  * @author Andreas Glaser
  */
 public function testIs()
 {
     $this->assertTrue(StringHelper::is($this->testString, 'Hello there, this is a test string.', true));
     $this->assertFalse(StringHelper::is($this->testString, 'Hello there, this is test string.', true));
     $this->assertTrue(StringHelper::is($this->testString, 'HELLO there, this is a TEST string.', false));
 }