I am new to PHP and I'm trying to convert a simple Javascript function into a PHP function. I need help converting this code to PHP. thanks so much
var intArrayToHexString = function(arr) {
var hex = "";
for (var i = 0; i < arr.length; i++) {
if (arr[i] < 16)
hex += "0";
hex += arr[i].toString(16);
}
return hex;
};
PHP code: to php, this is what I've tried:
function intArrayToHexString($arr) {
$hex = "";
for ($i = 0; $i < strlen($arr); $i++) {
if ($arr[$i] < 16)
$hex .= "0";
$hex .= $arr[$i];
}
return $hex;
};
PHP code does not work. Help me please.