Главная страница


ru.linux

 
 - RU.LINUX ---------------------------------------------------------------------
 From : Roman Skvirskij                      2:5020/400     11 Jan 2002  19:29:11
 To : Igor S.Kozhukhov
 Subject : Re: php
 -------------------------------------------------------------------------------- 
 
 Hello, Igor!
 You wrote to All on Thu, 10 Jan 2002 17:40:00 +0300:
 
  IS>                             Hello All!
 
  IS>    подскажите плиз - нужно получить слово из стоки на php - строку
  IS> из файла я получил fgets($fp, 150) - теперь как можно из ентой
  IS> строки получить слова - их в ней примерно 4 или 5 - не могу работать
  IS> с указателями как в Си - никак не могу разобраться - помогите плиз
  IS> ...
 split
 (PHP 3 <= 3.0.18, PHP 4 >= 4.0.0)
 
 split -- split string into array by regular expression
 Description
 
 array split (string pattern, string string [, int limit])
 Note: preg_split(), which uses a Perl-compatible regular expression syntax,
 is often a faster alternative to split().
 
 Returns an array of strings, each of which is a substring of string formed
 by splitting it on boundaries formed by the regular expression pattern. If
 limit is set, the returned array will contain a maximum of limit elements
 with the last element containing the whole rest of string. If an error
 occurs, split() returns FALSE.
 
 To split off the first four fields from a line from /etc/passwd: Example 1.
 split() Example
 
 list($user,$pass,$uid,$gid,$extra)= split (":", $passwd_line, 5);
 Tip: If there are n occurences of pattern, the returned array will contain
 n+1 items. For example, if there is no occurence of pattern, an array with
 only one element will be returned. Of course, this is also true if string is
 emply.
 
 To parse a date which may be delimited with slashes, dots, or hyphens:
 Example 2. split() Example
 
 $date = "04/30/1973";  // Delimiters may be slash, dot, or hyphen
 list ($month, $day, $year) = split ('[/.-]', $date);
 echo "Month: $month; Day: $day; Year: $year<br>\n";
 Note that pattern is case-sensitive.
 
 Note that if you don't require the power of regular expressions, it is
 faster to use explode(), which doesn't incur the overhead of the regular
 expression engine.
 
 For users looking for a way to emulate Perl's $chars = split('', $str)
 behaviour, please see the examples for preg_split().
 With best regards, Roman Skvirskij.  E-mail: roman@loveme.spb.ru
 
 --- ifmail v.2.15dev5
  * Origin: Demos online service (2:5020/400)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 php   Igor S.Kozhukhov   10 Jan 2002 18:40:00 
 Re: php   Roman Skvirskij   11 Jan 2002 19:29:11 
Архивное /ru.linux/4421542b1965.html, оценка 2 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional