I need to convert the following perl function to php:
pack(\"SSA12AC4L\",
$id,
$loc,
$name,
\'ar\',
split(/\\./, $get->getIP),
t
It looks like you're having trouble with the fact that in Perl, if a function call is placed in the middle of a parameter list, and the called function returns a list, the items in that list are "flattened" to produce multiple arguments to the outer function; PHP doesn't do anything similar, and that's where you're getting your argument mismatch (the split should be producing four arguments to pack, but PHP only sees one -- an array
value).
Fortunately the way around this is pretty easy, because there are builtin functions that will replicate what you need without any gymnastics. Try:
echo pack("SSA12ANL",
'25',
'00001',
'2u7wx6fd94fd',
'f',
ip2long('10.2.1.1'),
'1278761963');
or if that somehow fails:
echo pack("SSA12Aa4L",
'25',
'00001',
'2u7wx6fd94fd',
'f',
inet_pton('10.2.1.1'),
'1278761963');