★ wanayoo — archive 1999 http://www.php.net/manual/function.stristr.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Strings
Quick Reference
German version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Strings
* AddCSlashes
* AddSlashes
* bin2hex
* Chop
* Chr
* chunk_split
* convert_cyr_string
* count_chars
* crc32
* crypt
* echo
* explode
* flush
* get_html_translation_table
* get_meta_tags
* hebrev
* hebrevc
* htmlentities
* htmlspecialchars
* implode
* join
* levenshtein
* ltrim
* md5
* Metaphone
* nl2br
* ob_start
* ob_get_contents
* ob_end_flush
* ob_end_clean
* ob_implicit_flush
* Ord
* parse_str
* print
* printf
* quoted_printable_decode
* quotemeta
* rtrim
* sscanf
* setlocale
* similar_text
* soundex
* sprintf
* strcasecmp
* strchr
* strcmp
* strcspn
* strip_tags
* stripcslashes
* stripslashes
* stristr
* strlen
* str_pad
* strpos
* strrchr
* str_repeat
* strrev
* strrpos
* strspn
* strstr
* strtok
* strtolower
* strtoupper
* str_replace
* strtr
* substr
* substr_count
* substr_replace
* trim
* ucfirst
* ucwords
Manual: stristr
View the source code for this pageSearch the site



Previous page
 stripslashes
 Updated
Sat, 12 Aug 2000
strlen 
Next page


stristr

(PHP3 >= 3.0.6, PHP4 )

stristr --  Case-insensitive strstr()

Description

string stristr (string haystack, string needle)

Returns all of haystack from the first occurrence of needle to the end. needle and haystack are examined in a case-insensitive manner.

If needle is not found, returns false.

If needle is not a string, it is converted to an integer and applied as the ordinal value of a character.

See also strchr(), strrchr(), substr(), and ereg().


User Contributed Notes: stristr


alan@world.net
25-Feb-2000 02:07
In the PHP4.0 beta 4 pl1, the stristr() shows a strange behaviour. I wrote the following lines,

<pre>
$a = "aaaBBBcccDDD";
$b = stristr($a, "CCC");
echo $a;
</pre>

It prints "aaabbbcccddd", the original string $a become lower cased which it should be in earlier versions. Is it a bug or a feature ?
This makes all the printout goes wrong with my scripts.



joelgg@mindspring.com
15-Mar-2000 12:10
The same thing happens to me like it happens to Alan. Is there any plan on fixing this obvious bug? I assume what they are doing is converting the haystack to lowercase as well as the needle so that it will match no matter what the given case is, but shouldn't you reconvert the haystack back to it's previous case after finishing? That sound logical enough to me!


inan@canada.com
25-Mar-2000 03:54
In the same line as the comments above - be careful in code near a stristr call. It seems that php tries to reuse variables where possible so that in a code snippit like:
<pre>
$temp = $variable;
$output = stristr ($something, $variable);
</pre>
The variable $temp is converted to lowercase as well as $variable. (Just two pointers to the same location I guess). A workaround is to make the assignment line:
<pre>
$temp = $variable."";
</pre>
or even shorten the code to:
<pre>
$output = stristr($something, $variable."");
</pre>



bigmweb@altavista.com
14-Apr-2000 06:14
Written this way, all variables keep their original values:

<pre>$result = stristr($haystack."",$needle."")</pre>
Mike



 About Notes


Previous page
 stripslashes
 Updated
Sat, 12 Aug 2000
strlen 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.