Argument 2 passed to array_sort() must be callable, string given

user3718908

I have the following arrays:

  array (size=3)
    0 => 
      array (size=3)
        'id' => int 18
        'class' => string 'VIP' (length=3)
        'fee' => float 20
    1 => 
      array (size=3)
        'id' => int 19
        'class' => string 'VVIP' (length=4)
        'fee' => float 50
    2 => 
      array (size=3)
        'id' => int 20
        'class' => string 'STANDARD' (length=8)
        'fee' => float 5

  array (size=3)
    0 => 
      array (size=3)
        'id' => int 19
        'class' => string 'VVIP' (length=4)
        'fee' => int 50
    1 => 
      array (size=3)
        'id' => int 18
        'class' => string 'VIP' (length=3)
        'fee' => int 20
    2 => 
      array (size=3)
        'id' => int 20
        'class' => string 'STANDARD' (length=8)
        'fee' => int 5

Now i am trying to sort them both using array_sort in ascending order using the id.:

$array_1 = array_sort($array_1, 'id', SORT_ASC);
$array_2 = array_sort($array_2, 'id', SORT_ASC);

However i keep getting the following error:

Argument 2 passed to array_sort() must be callable, string given

Moppo

The second parameter of array_sort should be a closure, not a string:

$array_1 = array_sort( $array_1, function($value){
    return $value['id'];
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Argument 2 passed to array_sort() must be callable, string given

From Dev

Argument 2 passed to yii\db\conditions\HashConditionBuilder::build() must be of the type array, string given in Yii2

From Dev

Argument 2 passed to Aws\AwsClient::getCommand() must be of the type array, string given

From Dev

Laravel Typer error: Argument 1 passed to must be an instance of . string given

From Dev

Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given

From Dev

Why do I get "Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given"

From Dev

Argument 2 passed to Controller method must be in instance of Request, none given

From Dev

Type error: Argument 2 passed to Controller::createFormBuilder() must be of the type array, object given, called in

From Dev

Catchable Fatal Error: Argument 1 passed to ... must be an instance of ..., array given

From Dev

Catchable Fatal Error: Argument 1 passed to ... must be an instance of ..., array given

From Dev

Symfony 2 Embedded Forms: Catchable Fatal Error: Argument 1 passed to Entity::addProperty must be an instance of XX\MyClass, array given

From Dev

Symfony2: Form throws "Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be an array, object given" on submit

From Dev

Symfony2: Form throws "Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be an array, object given" on submit

From Dev

Argument 1 passed to App\Http\Controllers\UsoSueloController::store() must be an instance of Illuminate\Http\Request, string given

From Dev

Fatal error: Uncaught TypeError: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, string given in

From Dev

Argument 2 passed to App\Http\Controllers\ProfileController::store() must be an instance of App\Http\Requests\CreateProfileRequest, none given

From Dev

Symfony2 Catchable fatal error: Argument 1 passed to ... must be an instance of ... integer given, called in

From Dev

Symfony2: ContextErrorException: Catchable Fatal Error: Argument 1 passed to [...]::__construct() must implement interface [...] none given

From Dev

Catchable Fatal Error: Argument 4 passed to UsernamePasswordToken::__construct() must be an array, null given

From Dev

Catchable Fatal Error: Argument 3 passed to Symfony::render() must be an instance of Symfony\..\Response, array given

From Dev

Catchable Fatal Error: Argument 4 passed to UsernamePasswordToken::__construct() must be an array, null given

From Dev

Symfony 3.3 Update - Argument 5 passed to FrameworkBundle Translator must be of the type array, object given,

From Dev

PHP Catchable fatal error: Argument 1 passed to must be of the type array, null given, called in on line 208 and defined

From Dev

laravel Type error: Argument 1 passed to Illuminate\Database\Eloquent\Model::save() must be of the type array, object given

From Dev

Magento : 2 “Argument passed must be an instance of Customeractivation”

From Dev

use Guzzle 6 to request Ruckus public API, but get Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, boolean given

From Dev

TypeError: the first argument must be callable

From Dev

Argument passed in must be a string of 24 hex characters - I think it is

From Dev

When assigning attributes, you must pass a hash as an argument, String passed

Related Related

  1. 1

    Argument 2 passed to array_sort() must be callable, string given

  2. 2

    Argument 2 passed to yii\db\conditions\HashConditionBuilder::build() must be of the type array, string given in Yii2

  3. 3

    Argument 2 passed to Aws\AwsClient::getCommand() must be of the type array, string given

  4. 4

    Laravel Typer error: Argument 1 passed to must be an instance of . string given

  5. 5

    Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, string given

  6. 6

    Why do I get "Argument 1 passed to Illuminate\Database\Grammar::parameterize() must be of the type array, string given"

  7. 7

    Argument 2 passed to Controller method must be in instance of Request, none given

  8. 8

    Type error: Argument 2 passed to Controller::createFormBuilder() must be of the type array, object given, called in

  9. 9

    Catchable Fatal Error: Argument 1 passed to ... must be an instance of ..., array given

  10. 10

    Catchable Fatal Error: Argument 1 passed to ... must be an instance of ..., array given

  11. 11

    Symfony 2 Embedded Forms: Catchable Fatal Error: Argument 1 passed to Entity::addProperty must be an instance of XX\MyClass, array given

  12. 12

    Symfony2: Form throws "Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be an array, object given" on submit

  13. 13

    Symfony2: Form throws "Argument 1 passed to Doctrine\Common\Collections\ArrayCollection::__construct() must be an array, object given" on submit

  14. 14

    Argument 1 passed to App\Http\Controllers\UsoSueloController::store() must be an instance of Illuminate\Http\Request, string given

  15. 15

    Fatal error: Uncaught TypeError: Argument 1 passed to DOMNode::appendChild() must be an instance of DOMNode, string given in

  16. 16

    Argument 2 passed to App\Http\Controllers\ProfileController::store() must be an instance of App\Http\Requests\CreateProfileRequest, none given

  17. 17

    Symfony2 Catchable fatal error: Argument 1 passed to ... must be an instance of ... integer given, called in

  18. 18

    Symfony2: ContextErrorException: Catchable Fatal Error: Argument 1 passed to [...]::__construct() must implement interface [...] none given

  19. 19

    Catchable Fatal Error: Argument 4 passed to UsernamePasswordToken::__construct() must be an array, null given

  20. 20

    Catchable Fatal Error: Argument 3 passed to Symfony::render() must be an instance of Symfony\..\Response, array given

  21. 21

    Catchable Fatal Error: Argument 4 passed to UsernamePasswordToken::__construct() must be an array, null given

  22. 22

    Symfony 3.3 Update - Argument 5 passed to FrameworkBundle Translator must be of the type array, object given,

  23. 23

    PHP Catchable fatal error: Argument 1 passed to must be of the type array, null given, called in on line 208 and defined

  24. 24

    laravel Type error: Argument 1 passed to Illuminate\Database\Eloquent\Model::save() must be of the type array, object given

  25. 25

    Magento : 2 “Argument passed must be an instance of Customeractivation”

  26. 26

    use Guzzle 6 to request Ruckus public API, but get Argument 3 passed to GuzzleHttp\Client::request() must be of the type array, boolean given

  27. 27

    TypeError: the first argument must be callable

  28. 28

    Argument passed in must be a string of 24 hex characters - I think it is

  29. 29

    When assigning attributes, you must pass a hash as an argument, String passed

HotTag

Archive