mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 02:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@326716 c90b9560-bf6c-de11-be94-00142212c4b1
168 lines
4.7 KiB
XML
168 lines
4.7 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.substr-compare">
|
|
<refnamediv>
|
|
<refname>substr_compare</refname>
|
|
<refpurpose>Binary safe comparison of two strings from an offset, up to length characters</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>substr_compare</methodname>
|
|
<methodparam><type>string</type><parameter>main_str</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>str</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>case_insensitivity</parameter><initializer>false</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>substr_compare</function> compares <parameter>main_str</parameter>
|
|
from position <parameter>offset</parameter> with <parameter>str</parameter>
|
|
up to <parameter>length</parameter> characters.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>main_str</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The main string being compared.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>str</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The secondary string being compared.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>offset</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The start position for the comparison. If negative, it starts counting
|
|
from the end of the string.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>length</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The length of the comparison. The default value is the largest of the
|
|
length of the <parameter>str</parameter> compared to the length of
|
|
<parameter>main_str</parameter> less the
|
|
<parameter>offset</parameter>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>case_insensitivity</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
If <parameter>case_insensitivity</parameter> is &true;, comparison is
|
|
case insensitive.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns < 0 if <parameter>main_str</parameter> from position
|
|
<parameter>offset</parameter> is less than <parameter>str</parameter>, >
|
|
0 if it is greater than <parameter>str</parameter>, and 0 if they are equal.
|
|
If <parameter>offset</parameter> is equal to or greater than the length of
|
|
<parameter>main_str</parameter> or <parameter>length</parameter> is set and
|
|
is less than 1, <function>substr_compare</function> prints a warning and returns
|
|
&false;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.1.0</entry>
|
|
<entry>
|
|
Added the possibility to use a negative <parameter>offset</parameter>.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>A <function>substr_compare</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
echo substr_compare("abcde", "bc", 1, 2); // 0
|
|
echo substr_compare("abcde", "de", -2, 2); // 0
|
|
echo substr_compare("abcde", "bcg", 1, 2); // 0
|
|
echo substr_compare("abcde", "BC", 1, 2, true); // 0
|
|
echo substr_compare("abcde", "bc", 1, 3); // 1
|
|
echo substr_compare("abcde", "cd", 1, 2); // -1
|
|
echo substr_compare("abcde", "abc", 5, 1); // warning
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>strncmp</function></member>
|
|
</simplelist>
|
|
</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
|
|
-->
|