【问题标题】:AutoComplete Doesn't Suggest Capital Letter Input PHP and XML自动完成不建议输入大写字母 PHP 和 XML
【发布时间】:2012-04-01 03:45:44
【问题描述】:

我正在创建一个简单的表单,我希望在此表单中具有自动完成功能。 http://www.script-tutorials.com/autocomplete-with-php-jquery-mysql-and-xml/我阅读了本教程,并为我的数据创建了一个具有以下格式的 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”,它只会提示数据“标签”

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

谢谢。

【问题讨论】:

    标签: php autocomplete


    【解决方案1】:

    strpos() 函数区分大小写,因此它只会返回包含字母“a”的“tag”。如果你想要一个不区分大小写的检查,你应该使用stripos()

    【讨论】:

      猜你喜欢
      • 2020-08-21
      • 1970-01-01
      • 2015-10-19
      • 1970-01-01
      • 1970-01-01
      • 2019-12-24
      • 2011-06-08
      • 1970-01-01
      • 2020-09-21
      相关资源
      最近更新 更多