我想知道是否有一個庫實現類似SQL的接口來訪問數組中的數據,例如是否有查詢語言來過濾數組?
輸入:
[
['name' => 'Tom', 'age' => 27, 'location' => ['country' => 'GB']],
['name' => 'Jerry', 'age' => 16, 'location' => ['country' => 'LT']],
['name' => 'Stuart', 'age' => 26, 'location' => ['country' => 'GB']]
]
虛構查詢:
SELECT name, location.country FROM {input} WHERE age > 18 ORDER BY age DESC
將產生的變化:
[
['name' => 'Tom', 'location.country' => 'GB'],
['name' => 'Tom', 'location.country' => 'GB']
]
注意,我完全知道array_filter
和都實現,我可以當場放在一起。我正在尋找像接口一樣的查詢來訪問數據。
似乎每一個linq庫已經停產。我想知道是否因爲其他原因沒有用。我在「linq」名下找到的最新實現是https://github.com/Athari/YaLinqo。另一個是在我的答案中提到的ArrayQuery。 – Gajus