1--TEST--
2Test strncasecmp() function: usage variations - double quoted strings
3--FILE--
4<?php
5/* Prototype  : int strncasecmp ( string $str1, string $str2, int $len );
6 * Description: Binary safe case-insensitive string comparison of the first n characters
7 * Source code: Zend/zend_builtin_functions.c
8*/
9
10/* Test strncasecmp() function with various double quoted strings for 'str1', 'str2' */
11
12echo "*** Test strncasecmp() function: with double quoted strings ***\n";
13$strings = array(
14  "Hello, World",
15  "hello, world",
16  "HELLO, WORLD",
17  "Hello, World\n",
18  "Hello".chr(0)."World"
19);
20/* loop through to compare each string with the other string */
21$count = 1;
22for($index1 = 0; $index1 < count($strings); $index1++) {
23  echo "-- Iteration $count --\n";
24  for($index2 = 0; $index2 < count($strings); $index2++) {
25    var_dump( strncasecmp( $strings[$index1], $strings[$index2], (strlen($strings[$index1]) + 1) ) );
26  }
27  $count ++;
28}
29echo "*** Done ***\n";
30?>
31--EXPECTREGEX--
32\*\*\* Test strncasecmp\(\) function: with double quoted strings \*\*\*
33-- Iteration 1 --
34int\(0\)
35int\(0\)
36int\(0\)
37int\(-[1-9][0-9]*\)
38int\([1-9][0-9]*\)
39-- Iteration 2 --
40int\(0\)
41int\(0\)
42int\(0\)
43int\(-[1-9][0-9]*\)
44int\([1-9][0-9]*\)
45-- Iteration 3 --
46int\(0\)
47int\(0\)
48int\(0\)
49int\(-[1-9][0-9]*\)
50int\([1-9][0-9]*\)
51-- Iteration 4 --
52int\([1-9][0-9]*\)
53int\([1-9][0-9]*\)
54int\([1-9][0-9]*\)
55int\(0\)
56int\([1-9][0-9]*\)
57-- Iteration 5 --
58int\(-[1-9][0-9]*\)
59int\(-[1-9][0-9]*\)
60int\(-[1-9][0-9]*\)
61int\(-[1-9][0-9]*\)
62int\(0\)
63\*\*\* Done \*\*\*
64