Welcome Guest, Not a member yet? Register   Sign In
Array helper: dot search
#1

(This post was last modified: 04-25-2022, 02:56 PM by iRedds.)

The dot_array_search() function has strange behavior.

I am expecting a value that matches the key, or null if the key is not found. But

PHP Code:
dot_array_search('a.b.c', ['a' => ['b' => ['c' => 'c']) // return "c". Ok
dot_array_search('a.b.c', ['a' => ['b' => ['c']) // return "null". Ok. because the key "c" does not exist.

dot_array_search('a.b.c', ['a' => ['b' => 'b']) // return "b". why? key "c" does not exist and should return "null"

//but if we replace "b" with wildcard "*"
dot_array_search('a.*.c', ['a' => ['b' => 'b']) // return "null". Ok 
dot_array_search('a.*.c', ['a' => ['b' => []]) // return "null". Ok 

//but 
dot_array_search('a.*.c', ['a' => []) // return "empty array" ?? 
Reply


Messages In This Thread
Array helper: dot search - by iRedds - 04-25-2022, 02:56 PM
RE: Array helper: dot search - by ignitedcms - 04-26-2022, 12:46 PM
RE: Array helper: dot search - by pvt - 04-29-2022, 11:39 PM
RE: Array helper: dot search - by kenjis - 04-30-2022, 12:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB