Converting an array to individual variables
Argument lists may include the … token to denote that the function accepts a variable number of arguments. The arguments will be passed into the given variable as an array; for example:
You can use “…” with an array when calling functions to unpack the array or Traversable variable or literal into the argument list of individual variables.
$MyArrayValues = array();
$MyArrayValues[] = "A";
$MyArrayValues[] = "B";
SomeFunctionExpectingIndividualVariables($SomeValue, ...$MyArrayValues);
function SomeFunctionExpectingIndividualVariables ($Value1, , mixed &$var1 [, mixed &$... ])
Convert array to a string
$MyString = implode(", ", $MyArray); //Outputs each element seperated by ", "
Converting Strings To Numeric Arrays
function ConvertByteStringToByteArray($s)
{
return array_slice(unpack("C*", "\0".$s), 1);
}
function ConvertByteArrayToByteString(array $t)
{
return call_user_func_array(pack, array_merge(array("C*"), $t));
}
function lsbStr2ushortArray($s)
{
return array_slice(unpack("v*", "\0\0".$s), 1);
}
function ushortArray2lsbStr(array $t)
{
return call_user_func_array(pack, array_merge(array("v*"), $t));
}
function lsbStr2ulongArray($s)
{
return array_slice(unpack("V*", "\0\0\0\0".$s), 1);
}
function ulongArray2lsbStr(array $t)
{
return call_user_func_array(pack, array_merge(array("V*"), $t));
}
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.