Click here to Skip to main content
14,641,302 members
Rate this:
Please Sign up or sign in to vote.
See more:
hello
can anyone help me to change this to a PHP function


function (a) {
                var b = '';
                if (typeof a === 'string' && a.length % 2 === 0 && a.match(/^[a-f0-9]+$/i) instanceof Array) {
                    for (var i = 0; i < a.length; i += 2) {
                        b += String.fromCharCode(parseInt(a.substr(i, 2), 16))
                    }
                }
                return b
            }


What I have tried:

function Convert($a){
    $b = "";
if ((isset($a) ? ($a) : "undefined") === "string" && (float)(to_number(get($a, "length")) % 2.0) === 0.0 && _instanceof(call_method($a, "match", new RegExp("^[a-f0-9]+\$", "i")), $Array)) {
  for ($i = 0.0; $i < get($a, "length"); $i = _plus($i, 2.0)) {
    $b = _plus($b, call_method($String, "fromCharCode", call($parseInt, call_method($a, "substr", $i, 2.0), 16.0)));
  }
}
return $b;}
Posted
Comments
Richard MacCutchan 13-Jun-20 4:09am
   
What are you trying to do, and why are you using float types for integral values?
skardus com 13-Jun-20 9:05am
   
what should be done?
Richard MacCutchan 13-Jun-20 9:36am
   
How could I know? I have no idea what that code is for. You need to explain what it is supposed to be doing, and why it does not work.
skardus com 13-Jun-20 12:34pm
   
change the youtube video id 11 digits to 32 digits
initial id: sWsXOGnH0uM
Becomes: cd485abf6137753785f474e6840357d4
skardus com 15-Jun-20 6:41am
   
hello Richard MacCutchan
Richard MacCutchan 15-Jun-20 9:03am
   
??
skardus com 15-Jun-20 9:07am
   
can you help?
Richard MacCutchan 15-Jun-20 9:52am
   
With what? All you have told us is that you want to convert "sWsXOGnH0uM" to "cd485abf6137753785f474e6840357d4". But we have no idea what your problem is.
skardus com 15-Jun-20 11:52am
   
How to change this command into a PHP function
Richard MacCutchan 15-Jun-20 12:18pm
   
Sorry, but I cannot figure out what all those compound expressions are supposed to do.
skardus com 15-Jun-20 12:23pm
   
this is file JS. you can see it
Richard MacCutchan 15-Jun-20 12:24pm
   
And I am supposed to guess what that code is supposed to do?
skardus com 15-Jun-20 12:29pm
   
yes, please help me sir
Richard MacCutchan 15-Jun-20 15:57pm
   
I have tried your Javascript code but it does not do the conversion that you showed. I have tried a number of different modifications to the code but it does not produce the right answer.
skardus com 15-Jun-20 16:35pm
   
ok thanks
Maciej Los 18-Jun-20 7:01am
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100