2012-04-01 54 views
0

我正在创建一个简单的表单,并且在此表单中我想要有一个自动完成功能。 http://www.script-tutorials.com/autocomplete-with-php-jquery-mysql-and-xml/我阅读本教程,和我的数据,我创建具有以下格式的XML文件,自动完成不会建议大写字母输入PHP和XML

<inputs> 
    <input>AA</input> 
    <input>BAC</input> 
    <input>AWT</input> 
    <input>tag</input> 
    <input>AHY</input> 
</inputs> 

和处理的自动完成是

$aValues = $aIndexes = array(); 
     $sFileData = file_get_contents('data2.xml'); // reading file content 
     $oXmlParser = xml_parser_create('UTF-8'); 
     xml_parse_into_struct($oXmlParser, $sFileData, $aValues, $aIndexes); 
     xml_parser_free($oXmlParser); 

     $aTagIndexes = $aIndexes['ITEM']; 
     if (count($aTagIndexes) <= 0) exit; 
     foreach($aTagIndexes as $iTagIndex) { 
      $sValue = $aValues[$iTagIndex]['value']; 
      if (strpos($sValue, $sParam) !== false) { 
       echo $sValue . "\n"; 
      } 
     } 
    break; 

但问题是方法,当我在输入字段时,它总是建议小写的数据。例如,如果我输入“A”或“a”,它只会提示数据'标记'

问题是什么,我该如何解决这个问题?

谢谢。

回答

4

strpos()功能区分大小写,所以它只会返回包含字母“a”的“标签”。如果你想进行不区分大小写的检查,你应该使用stripos()

+0

哦,非常感谢你! – CanCeylan 2012-04-01 03:53:32