0

我想知道是否有一种简单的方法可以将数组键与 logo_id 匹配?

如果我找不到方法来做到这一点,我将需要使用数组搜索,这对于包含 200 个项目的数组来说会变得非常慢。正确的?

ps 这是 mysqli fetch 结果调用返回的结果。也许可以修改它以提供我需要的数组?

                                Array
(
    [0] => Array
        (
            [logo_id] => 1
            [logo_name] => beeline
            [logo_level] => 1
            [logo_image_path] => logos/1.png
            [logo_value] => 2
            [logo_hints] => 
        )

    [1] => Array
        (
            [logo_id] => 2
            [logo_name] => geocell
            [logo_level] => 1
            [logo_image_path] => logos/2.png
            [logo_value] => 4
            [logo_hints] => 
        )

    [2] => Array
        (
            [logo_id] => 3
            [logo_name] => google
            [logo_level] => 1
            [logo_image_path] => logos/3.png
            [logo_value] => 5
            [logo_hints] => 
        )

    [3] => Array
        (
            [logo_id] => 5
            [logo_name] => coca cola
            [logo_level] => 1
            [logo_image_path] => logos/5.png
            [logo_value] => 2
            [logo_hints] => 
        )

)

我解释得好吗?phh,抱歉措辞不好。

4

1 回答 1

2

这是 mysqli fetch 结果调用返回的结果。也许可以修改它以提供我需要的数组?

是的。我假设你的意思是mysqli_result::fetch_all。而是在循环中使用mysqli_result::fetch_row并使用您喜欢的任何键手动构建您的数组。

于 2013-03-01T14:58:11.447 回答