2003-11-02 16:48:28 +00:00
|
|
|
<?xml version='1.0' encoding='iso-8859-1'?>
|
2007-06-20 22:25:43 +00:00
|
|
|
<!-- $Revision: 1.6 $ -->
|
|
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.substr-compare">
|
2007-06-15 19:01:26 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>substr_compare</refname>
|
2007-06-15 19:01:57 +00:00
|
|
|
<refpurpose>Binary safe comparison of 2 strings from an offset, up to length characters</refpurpose>
|
2007-06-15 19:01:26 +00:00
|
|
|
</refnamediv>
|
2007-06-15 19:01:57 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2007-06-15 19:01:26 +00:00
|
|
|
<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></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>
|
2007-06-15 19:01:57 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>main_str</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>str</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>offset</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The start position for the comparison.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>length</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The length of the comparison.
|
|
|
|
</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;
|
2007-06-15 19:01:26 +00:00
|
|
|
<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>length</parameter> is equal or greater than length of
|
|
|
|
<parameter>main_str</parameter> and <parameter>length</parameter> is set,
|
|
|
|
<function>substr_compare</function> prints warning and returns &false;.
|
|
|
|
</para>
|
2007-06-15 19:01:57 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
2007-06-15 19:01:26 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>A <function>substr_compare</function> example</title>
|
|
|
|
<programlisting role="php">
|
2004-04-26 17:43:26 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
|
|
|
echo substr_compare("abcde", "bc", 1, 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
|
|
|
|
?>
|
|
|
|
]]>
|
2007-06-15 19:01:26 +00:00
|
|
|
</programlisting>
|
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
2007-06-15 19:01:57 +00:00
|
|
|
|
2007-06-15 19:01:26 +00:00
|
|
|
</refentry>
|
2003-11-02 16:48:28 +00:00
|
|
|
|
|
|
|
<!-- 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:"../../../../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
|
|
|
|
-->
|