-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathstrtok.xml
More file actions
124 lines (123 loc) · 3.71 KB
/
strtok.xml
File metadata and controls
124 lines (123 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?xml version="1.0" encoding="UTF-8"?>
<!-- EN-Revision: n/a Maintainer: darvina Status: ready -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
<refentry xml:id="function.strtok" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>strtok</refname>
<refpurpose>Suddivide una stringa in token</refpurpose>
</refnamediv>
<refsect1>
<title>Descrizione</title>
<methodsynopsis>
<type>string</type><methodname>strtok</methodname>
<methodparam><type>string</type><parameter>str</parameter></methodparam>
<methodparam><type>string</type><parameter>token</parameter></methodparam>
</methodsynopsis>
<para>
<function>strtok</function> suddivide la stringa(<parameter>str</parameter>)
in piccole stringhe (tokens), in cui ciascun token è delimitato dal
carattere indicato in <parameter>token</parameter>.
Perciò, se si ha la stringa "This is an example string" la si può
dividere nelle singole parole utilizzando come separatore
lo spazio.
<example>
<title>Esempio di uso di <function>strtok</function></title>
<programlisting role="php">
<![CDATA[
<?php
$string = "This is\tan example\nstring";
/* Use tab and newline as tokenizing characters as well */
$tok = strtok($string, " \n\t");
while ($tok !== false) {
echo "Word=$tok<br />";
$tok = strtok(" \n\t");
}
?>
]]>
</programlisting>
</example>
</para>
<para>
Soltanto la prima chiamata a <function>strtok</function> utilizza il parametro stringa.
Ogni chiamata successiva richiede solo il carattere da utilizzare, poiché
la funzione tiene traccia di dove è arrivata nella stringa corrente. Per ripartire da capo
o iniziare con una nuova stringa ri-chiamare <function>strtok</function>
con il parametro stringa. Nota: si possono mettere più caratteri
come separatori di stringhe. Il testo iniziale verrà suddiviso
quando viene trovato uno qualsiasi di questi caratteri.
Attenzione che soltanto la prima chiamata di strtok userà l'argomento stringa.
</para>
<para>
Il comportamento su segmenti vuoti è cambiato dal PHP 4.1.0. La vecchia
versione restituiva una stringa vuota, mentre la nuova, più correttamente,
salta quella parte di stringa:
<example>
<title>Vecchio comportamento di <function>strtok</function></title>
<programlisting role="php">
<![CDATA[
<?php
$first_token = strtok('/something', '/');
$second_token = strtok('/');
var_dump($first_token, $second_token);
?>
]]>
</programlisting>
<para>
Output:
</para>
<screen>
<![CDATA[
string(0) ""
string(9) "something"
]]>
</screen>
</example>
<example>
<title>Nuovo comportamento di <function>strtok</function></title>
<programlisting role="php">
<![CDATA[
<?php
$first_token = strtok('/something', '/');
$second_token = strtok('/');
var_dump($first_token, $second_token);
?>
]]>
</programlisting>
<para>
Output:
</para>
<screen>
<![CDATA[
string(9) "something"
bool(false)
]]>
</screen>
</example>
</para>
&return.falseproblem;
<para>
Vedere anche: <function>split</function> e
<function>explode</function>.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->