1

EDIT: I added a repository in github. In "welcome" the result is printed. https://github.com/Danven/borrar

LARAVEL 5.8

WITH VAR_DUMP (DIFFERENT!!!!)

{{ var_dump( $person->cars()->pluck('cars.id') )  }}

LOCAL MACHINE (PHP 7.3.7 ):

object(Illuminate\Support\Collection)#1215 (1) {
  ["items":protected]=>
  array(4) {
    [0]=> int(1)
    [1]=> int(2)
    [2]=> int(3)
    [3]=> int(4)
  }
}

PRODUCTION SERVER (PHP 7.2.12) :

object(Illuminate\Support\Collection)#1215 (1) {
  ["items":protected]=>
  array(4) {
    [0]=> string(1) "1"
    [1]=> string(1) "2"
    [2]=> string(1) "3"
    [3]=> string(1) "4"
  }
}
Dan Ven
  • 11
  • 3
  • See this post it because of differences between var_dumb and print_r https://stackoverflow.com/questions/3406171/php-var-dump-vs-print-r –  Jan 23 '20 at 17:30

1 Answers1

0

Because in PHP 7.3 Strings containing valid decimal integers, unless the number is preceded by a + sign, will be cast to the integer type. E.g. the key 8 will actually be stored under 8. On the other hand 08 will not be cast, as it isn't a valid decimal integer.

You can read that on: https://www.php.net/manual/en/language.types.array.php

Jouby
  • 2,196
  • 2
  • 21
  • 33
  • I have tested it on another server with PHP 7.1.33 and PHP Version 7.2.26 with Production status: `[1,2,3,4]` . The values are interpreted as integers – Dan Ven Jan 23 '20 at 19:58