小编Ano*_*ous的帖子

如何在 PHP 中使用 array_flip 翻转多维数组

我有带有键值对的多维数组,所以我想翻转,即键到达值位置,值到达键位置,但我收到错误

我的 PHP 代码是:

echo '<pre>',print_r($res),'</pre>';
Run Code Online (Sandbox Code Playgroud)

print_r($res) 时的输出:

Array
(
    [0] => Array
        (
            [userid] => 1
        )

    [1] => Array
        (
            [userid] => 2
        )

    [2] => Array
        (
            [userid] => 3
        )

)
Run Code Online (Sandbox Code Playgroud)

当想要翻转此数组时,输出出现错误:

array_flip(): Can only flip STRING and INTEGER values!
Run Code Online (Sandbox Code Playgroud)

怎么解决这个问题呢?

php arrays

2
推荐指数
1
解决办法
5965
查看次数

如何在 Php 中使用谷歌货币 API 转换货币?

我通过使用 file_get_content 在 php 中使用谷歌货币转换 API,但由于出现错误而无法获取输出,那么如何通过在 Php 中使用以下 API 来转换任何货币。

<?php  
 function convertCurrency($amount, $from, $to)  
 {  
      $url = "http://www.google.com/finance/converter?a=$amount&from=$from&to=$to";  
      $data = file_get_contents($url);  
      preg_match("/<span class=bld>(.*)<\/span>/",$data, $converted);  
      return $converted[1];  
 }  
 echo convertCurrency(1500, 'USD', 'INR');  
 ?> 
Run Code Online (Sandbox Code Playgroud)

出现这样的错误

Message: file_get_contents(http://www.google.com/finance/converter?a=1500&from=USD&to=INR): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden
Run Code Online (Sandbox Code Playgroud)

php api currency

1
推荐指数
1
解决办法
2万
查看次数

使用jQuery在眼睛图标上单击时如何显示和隐藏密码

我要求在单击眼睛图标时显示和隐藏用户密码,因此我为此编写了脚本,当我单击眼睛图标时,只有类正在更改,但密码不可见,然后再次单击斜线图标,则应将这两个都隐藏方法不起作用怎么解决这个问题?

<input type="password" name="player_password" id="pass_log_id" />

<span toggle="#password-field" class="fa fa-fw fa-eye field_icon toggle-password"></span>

<script>
$("body").on('click','.toggle-password',function(){
    $(this).toggleClass("fa-eye fa-eye-slash");

    var input = $("#pass_log_id").attr("type");

    if (input.attr("type") === "password") {
        input.attr("type", "text");
    } else {
        input.attr("type", "password");
    }
});
</script>
Run Code Online (Sandbox Code Playgroud)

javascript jquery

1
推荐指数
3
解决办法
9000
查看次数

标签 统计

php ×2

api ×1

arrays ×1

currency ×1

javascript ×1

jquery ×1