пятница, 23 декабря 2011 г.

PHP String 3

int strcasecmp ( string $str1 , string $str2 ) = unikoda tekstam neder. 0 - ja teksti ir viendi, >0 ja pirmais mazāks par otro
int strcmp ( string $str1 , string $str2 )
int strcoll ( string $str1 , string $str2 )
string strip_tags ( string $str [, string $allowable_tags ] )
string stripcslashes ( string $str ) => uneskeipo aizvac backsleshus, atpazist "/n" "/r"

int stripos ( string $haystack , string $needle [, int $offset = 0 ] ) => atrod needle un atgriež poziciju
0 ir pirma pozicijA!
if(stripos('abc','bca') === false){


}
--------
______________
string stripslashes ( string $str ) => aizvāc slešus, dubultie slesi tiek padarīti par vienkāršiem slešiem

string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] ) => needle - meklētais teksts
before_needle - no sākuma, līdz beigām; atrod pirmo poziciju kur atrasts, un atgriež visu tekstu no šīs pozicijas līdz haystack beigam. Ja neatrod, atgriiež visu pie $before_needle = false
______________

string strtok ( string $str , string $token ) => pirmais elements no explode vai explode ar trešo argumentu

$string = "aaaaa 
sdfsdfsdf
sdfsfsdf
sdfsfdf
sfsdfsdfsd
";
$tok = strtok($string, "\n");


while ($tok !== false) {
    echo "$tok".PHP_EOL;
    $tok = strtok(" \n\t");
}
---------
aaaaa 
sdfsdfsdf
sdfsfsdf
sdfsfdf
sfsdfsdfsd
________________
string strtolower ( string $str ) => visu tekstu mazajos burtos
string strtoupper ( string $string ) => visu tekstu lielajos burtos
string strtr ( string $str , string $from , string $to ) => string translete;  

strtr($addr, "äåö", "aao");
---------------------
$trans = array("h" => "-", "hello" => "hi", "hi" => "hello");
echo strtr("hi all, I said hello", $trans);
-----------
hello all, I said hi
_____________________
$string = "hello";

$arr1 = array("h","e","l","o");
$arr2 = array("1","2","3","4");

echo str_replace($arr1,$arr2,$string);
---------
12334
_____________________
mixed substr_replace ( mixed $string , mixed $replacement , mixed $start [, mixed $length ] ) => aizvietojam vienu tekstu ar otro.
string substr ( string $string , int $start [, int $length ] ) => 
string trim ( string $str [, string $charlist ] ) => no abam pussem attra str  no charlist 
string ucfirst ( string $str ) => teksta pirmo burtu par lielo burtu
string ucwords ( string $str ) => katru vardu teksta parv par lielo burtu pirmu burtu: Nosaukumu normalizācija. No sakuma visus uz maziem, pēc tam ar ucwords;
string wordwrap ( string $str [, int $width = 75 [, string $break = "\n" [, bool $cut = false ]]] ) => izdala pa 75 simboliem,  sadala ar noradīto break simbolu.

$text = "The quick brown fox jumped over the dog. ****************************";
$newtext = wordwrap($text, 10, "\n");

echo $newtext;
-------------
The quick
brown fox
jumped
over the
dog.
****************************
__________________________

$text = "The quick brown fox  ******************************* dog.";
$newtext = wordwrap($text, 10, "\n",true);

echo $newtext;
-----------
The quick
brown fox 
**********
**********
**********
* dog.
__________________________
$text = "The quick brown fox  ******************************* dog.";
$newtext = wordwrap($text, 10, "\n",false);

echo $newtext;
--------------
The quick
brown fox 
*******************************
dog.
_________________________











Комментариев нет:

Отправить комментарий