本文整理汇总了PHP中String::contains方法的典型用法代码示例。如果您正苦于以下问题:PHP String::contains方法的具体用法?PHP String::contains怎么用?PHP String::contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类String
的用法示例。
在下文中一共展示了String::contains方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testContains
public function testContains()
{
$string = new String("Test5");
$this->assertTrue($string->contains("e"));
$this->assertFalse($string->contains("X"));
$this->assertTrue($string->contains("E", true));
$this->assertFalse($string->contains("E", false));
}
示例2: close
/**
* Performs te closure of the session of a project.<br>
* @param string $project The name of the current project
*/
public static function close($project)
{
$this->activate();
reset($_SESSION);
while (list($key, $val) = each($_SESSION)) {
if (String::contains($key, $project)) {
$this->deleteValue($key);
}
}
reset($_SESSION);
}
示例3: assertNotContains
/**
* @param mixed $value_
* @param string $pattern_
*
* @return boolean|false If given array/string does contain given pattern.
*/
function assertNotContains($value_, $pattern_)
{
$message = Assertion_Helper::getMessage('Expected any type not containing a key/value matching given pattern', __FUNCTION__, func_get_args());
if (is_array($value_)) {
if (false !== Arrays::containsKeyBySubstring($value_, $pattern_, Arrays::RECURSIVE) || false !== Arrays::containsValueBySubstring($value_, $pattern_, Arrays::RECURSIVE)) {
Assertion_Context::current()->add(__FUNCTION__, false, $message);
return false;
}
} else {
if (String::contains($value_, $pattern_)) {
Assertion_Context::current()->add(__FUNCTION__, false, $message);
return false;
}
}
Assertion_Context::current()->add(__FUNCTION__, true, $message);
return true;
}
示例4: containsValueBySubstring
public static function containsValueBySubstring(array $array_, $substring_, $mode_ = 3, array &$parentKeys_ = [])
{
$exists = false;
$nestedArrays = [];
$recursive = Bitmask::hasBitForBitmask($mode_, self::RECURSIVE);
// search current level
foreach ($array_ as $key => $value) {
if (is_array($value)) {
$nestedArrays[] = $key;
} else {
if (false === $exists) {
$exists = String::contains($value, $substring_);
if (false !== $exists) {
$exists = $key;
if (false === $recursive) {
return $exists;
}
}
}
}
}
if (false === $recursive) {
return $exists;
}
// proceed with nested levels if requested
foreach ($nestedArrays as $nestedArray) {
$exists = self::containsValueBySubstring($array_[$nestedArray], $substring_, $mode_, $parentKeys_);
if (false !== $exists) {
array_unshift($parentKeys_, $nestedArray);
return $exists;
}
}
return $exists;
}
示例5: contains
public function contains()
{
$str = new String('H�llo');
$this->assertTrue($str->contains('H'));
$this->assertTrue($str->contains('�'));
$this->assertTrue($str->contains('o'));
$this->assertFalse($str->contains(''));
$this->assertFalse($str->contains('4'));
}
示例6: inString
/**
* A faster/less memory substitute for strstr() or preg_match
* used to check the occurrence of a subject in a string.
*
* @param string $needle
* @param array $haystack
* @return bool
**/
public static function inString($needle, $haystack)
{
return String::contains($needle, $haystack);
}
示例7: String
include('lib/Common.java.php');
include('lib/System.java.php');
include('lib/String.java.php');
include('lib/File.java.php');
// Initialize a String
$hello = new String("World");
// Show it lowercase
out::prntln("Lowercase of '{$hello->toString()}': " . $hello->toLowerCase());
// Show the string's equality without case
out::prntln("EqualsIgnoreCase test against 'world': " . (($hello->equalsIgnoreCase("world")) ? 'true' : 'false'));
// Show the string's containment for "e"
out::prntln("Contains 'e'? " . (($hello->contains("e")) ? 'true' : 'false'));
// Show the last index of o
out::prntln("Last index of 'o': " . ((!$hello->lastIndexOf("o")) ? 'false' : $hello->lastIndexOf("o")));
// ----------------------------------------------------- //
// New Section
out::prntln();
// ----------------------------------------------------- //
// Initialize a File
$file = new File("index.php");
// Get the name
示例8: MySQLHandler
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . "/LIB/libMySQL.php";
include $_SERVER['DOCUMENT_ROOT'] . 'KhunluungramnerkP/loginMySQL.php';
$handler = new MySQLHandler('localhost', 'khunluungramnerk', $usrDB["user"], $usrDB["passwd"]);
$handler->conn();
$getPalabra = array("tipo" => "SELECT", "campos" => array("id, palabra_et, posición, raíz"), "tablas" => "etim_raiz");
$handler->query($getPalabra);
foreach ($handler->data->lista as $etimología) {
var_dump($etimología);
$id = $etimología["id"];
$RaizCompuesta = new String($etimología["raíz"]);
if ($RaizCompuesta->contains('-')) {
$RaizCompuesta = explode('-', $RaizCompuesta->get());
$RaizCompuesta[1] = '-' . $RaizCompuesta[1];
$primer = new String($RaizCompuesta[0]);
if ($primer->equals('')) {
unset($RaizCompuesta[0]);
}
} elseif ($RaizCompuesta->contains('+')) {
$RaizCompuesta = explode('+', $RaizCompuesta->get());
}
var_dump($RaizCompuesta);
$elimRaizPrevia = array("tipo" => "DELETE", "tabla" => "etim_raiz", "condicion" => array("id" => $id));
$handler->query($elimRaizPrevia);
$i = 1;
foreach ($RaizCompuesta as $raiz) {
$insertRaiz = array("tipo" => "INSERT", "campos" => array("id" => $id, "posición" => $i, "raíz" => $raiz), "tabla" => "etim_raiz");
$handler->query($insertRaiz);
$i++;
}
}