ich bin dabei, einige - meiner Meinung nach nützliche - PHP-Funktionen (in möglichst gleicher Funktionsweise) in AHK zu "importieren".
Dabei soll das Verhalten sowie der Aufruf möglichst nah an der originellen PHP-Funktion gehalten werden.
Hier mal mein Anfang:
Code: Select all
count(var, mode=0){
if(var = "")
return 0
if(!IsObject(var))
return 1
count := 0
if(mode = 0){
for i, k in var
count++
}
else if(mode = 1){
this := var
RecursiveCounting:
for i, k in this
{
count ++
if(IsObject(k)){
this := k
gosub RecursiveCounting
}
}
return count
}
return count
}
print_r(input){
output := ""
if(!IsObject(input))
return input
this := input
tabs := ""
ThisArray:
if(IsObject(this)){
output .= "Array`n" tabs "(`n"
tabs .= "`t"
for i, k in this
{
if(IsObject(k)){
this := k
output .= tabs "[" i "] => "
gosub ThisArray
}
else
output .= tabs "[" i "] => " k "`n"
}
tabs := SubStr(tabs, 1, -1)
output .= tabs ")`n"
}
return Trim(output, "`n")
}
time(timestamp="UTC") {
if(timestamp = "UTC")
timestamp := A_NowUTC
timestamp -= 1970, S
return timestamp
}