unpacking an array of arguments in php

后端 未结 5 1982
醉话见心
醉话见心 2020-12-15 04:11

Python provides the \"*\" operator for unpacking a list of tuples and giving them to a function as arguments, like so:

args = [3, 6]
range(*args)                     


        
5条回答
  •  失恋的感觉
    2020-12-15 04:56

    In certain scenarios, you might consider using unpacking, which is possible in php, is a similar way to python:

    list($min, $max) = [3, 6];
    range($min, $max);
    

    This is how I have arrived to this answer at least. Google search: PHP argument unpacking

提交回复
热议问题