Using usort in php with a class private function

后端 未结 5 992
闹比i
闹比i 2020-12-02 07:10

ok using usort with a function is not so complicated

This is what i had before in my linear code

function merchantSort($a,$b){
    return ....// stuf         


        
5条回答
  •  悲哀的现实
    2020-12-02 07:48

    In Laravel (5.6) model class, I called it like this, both methods are public static, using php 7.2 on windows 64 bit.

    public static function usortCalledFrom() 
    
    public static function myFunction()
    

    I did call in usortCalledFrom() like this

    usort($array,"static::myFunction")
    

    None of these were work

    usort($array,"MyClass::myFunction")
    usort($array, array("MyClass","myFunction")
    

提交回复
热议问题