This package implements some PHP functions by Golang. Please note that it's impossible to have 100% the same behaviour between PHP and Golang functions because their mechanisms are quite different.
go get github.com/imartingraham/php
import (
"fmt"
"github.com/imartingraham/php"
)
// Date/Time functions
fmt.Println(php.Strtotime("2017-07-14 02:40:00")) // output: 1500000000
fmt.Println(php.Strtotime("2017-07-14T10:40:00+08:00")) // output: 1500000000
fmt.Println(php.Date("Y-m-d H:i:s", 1500000000)) // output: 2017-07-14 02:40:00
fmt.Println(php.Date("c", 1500000000)) // output: 2017-07-14T02:40:00+00:00
// String functions
str := "abcdef"
fmt.Println(php.Substr(str, 1, 0)) // bcdef
fmt.Println(php.Substr(str, 1, 3)) // bcd
fmt.Println(php.Substr(str, 0, 4)) // abcd
fmt.Println(php.Substr(str, -1, 1)) // f
fmt.Println(php.Substr(str, 0, -1)) // abcde
// Math functions
fmt.Println(php.Round(5.055, 2)) // 5.06
// Array functions
arr := []string{"1", "1", "2", "3", "a", "ab", "abc", "abc", "abc", "Abc"}
fmt.Println(php.ArrayUnique(arr).([]string)) // [abc Abc 1 2 3 a ab]
fmt.Println(php.InArray("a", arr)) // true