func_num_args摆脱了第一个值

时间:2015-01-15 12:32:50

标签: php mysqli

嗨我什么摆脱了func_num_args中的一个值我已经格式化它但是第一个值我不需要这里我的代码

感谢

    [1] => 14 [2] => user_id [3] => username [4] => password [5] => first_name [6] => last_name [7] => email [8] => type )

     function user_data($con,$user_id)
    {
    $con = mysqli_connect("localhost","root","","bear") or die ($connect_error);
    $data = array();
    $user_id = (int)$user_id;

    $func_num_args = func_num_args();
    $func_get_args = func_get_args();

    print_r ($func_get_args);
    if ($func_num_args > 1)
    {
    unset($func_get_args[0]);

    $fields = '`' . implode('`, `' , $func_get_args) . '`';
    //$fields = substr($fields, 4);
    echo $fields;

    $data = mysqli_fetch_assoc(mysqli_query($con,"SELECT  $fields FROM `users` WHERE `user_id` = $user_id"));
    return $data;
    print_r($data);
    }

我需要摆脱它,因为将格式化的func_num_args放入$ field变量,然后将其传递给mysqli语句

我可以使用substr但是每个用户需要更改substr的数量

0 个答案:

没有答案