Convert a Perl code to PHP

前端 未结 8 1499
粉色の甜心
粉色の甜心 2021-01-29 08:50

I need to convert the following perl function to php:

pack(\"SSA12AC4L\",
     $id,
     $loc,
     $name,
     \'ar\',
     split(/\\./, $get->getIP),
     t         


        
8条回答
  •  借酒劲吻你
    2021-01-29 09:46

    I think that the problem is that preg_split returns an array. So the array is inserted as the first char, the time as the second, and two chars are left.

    I don't know how to fix this problem, but to create a temporary array:

    $ip = explode('.','10.2.1.1');
    

    And then:

    echo pack("SSA12AC4L",
     '25',
     '00001',
     '2u7wx6fd94fd',
     'f',
     $ip[0],
     $ip[1],
     $ip[2]
     $ip[3],
     time()+(60*60));
    

提交回复
热议问题