mirror of
https://github.com/php/doc-ja.git
synced 2026-04-27 18:13:11 +02:00
201 lines
5.7 KiB
XML
201 lines
5.7 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 4b72b23513caa3a8bc520d459a0417defc7b3880 Maintainer: takagi Status: ready -->
|
|
<!-- CREDITS: hirokawa,mumumu -->
|
|
<refentry xml:id="function.stripos" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>stripos</refname>
|
|
<refpurpose>大文字小文字を区別せずに文字列が最初に現れる位置を探す</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>int</type><type>false</type></type><methodname>stripos</methodname>
|
|
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>needle</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>offset</parameter><initializer>0</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
文字列 <parameter>haystack</parameter> の中で
|
|
<parameter>needle</parameter> が最初に現れる位置を探します。
|
|
</para>
|
|
<para>
|
|
<function>strpos</function> と異なり、<function>stripos</function>
|
|
は大文字小文字を区別しません。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>haystack</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
検索対象の文字列。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>needle</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
検索する文字列。
|
|
</para>
|
|
&strings.parameter.needle.non-string;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>offset</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
指定すると、文字列内での検索開始位置がその位置になります。
|
|
負の数を指定すると、文字列の末尾からこの数だけ戻った場所から検索を開始します。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
needle が見つかった位置を、
|
|
<parameter>haystack</parameter> 文字列の先頭 (offset の値とは無関係) からの相対位置で返します。
|
|
文字列の開始位置は 0 であり、1 ではないことに注意しましょう。
|
|
</para>
|
|
<para>
|
|
needle が見つからない場合は &false; を返します。
|
|
</para>
|
|
&return.falseproblem;
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
<parameter>offset</parameter> が <parameter>haystack</parameter>
|
|
の長さより大きい場合、
|
|
<classname>ValueError</classname> がスローされます。
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&strings.changelog.ascii-case-folding;
|
|
&strings.changelog.needle-empty;
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
<parameter>needle</parameter> に数値を渡すことはサポートされなくなりました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7.3.0</entry>
|
|
<entry>
|
|
<parameter>needle</parameter> に数値を渡すことは非推奨になりました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7.1.0</entry>
|
|
<entry>
|
|
負の <parameter>offset</parameter> をサポートするようになりました。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>stripos</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$findme = 'a';
|
|
$mystring1 = 'xyz';
|
|
$mystring2 = 'ABC';
|
|
|
|
$pos1 = stripos($mystring1, $findme);
|
|
$pos2 = stripos($mystring2, $findme);
|
|
|
|
// いいえ、'a' は明らかに 'xyz' の中には存在しません
|
|
if ($pos1 === false) {
|
|
echo "The string '$findme' was not found in the string '$mystring1'", PHP_EOL;
|
|
}
|
|
|
|
// !== を使用していることに注意しましょう。単に != としても期待通りに動作
|
|
// しません。なぜなら 'a' は 0 番目(最初) の文字だからです。
|
|
if ($pos2 !== false) {
|
|
echo "We found '$findme' in '$mystring2' at position $pos2", PHP_EOL;
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
¬e.bin-safe;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>mb_stripos</function></member>
|
|
<member><function>str_contains</function></member>
|
|
<member><function>str_ends_with</function></member>
|
|
<member><function>str_starts_with</function></member>
|
|
<member><function>strpos</function></member>
|
|
<member><function>strrpos</function></member>
|
|
<member><function>strripos</function></member>
|
|
<member><function>stristr</function></member>
|
|
<member><function>substr</function></member>
|
|
<member><function>str_ireplace</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
|
|
-->
|