It is possible with the count function, like so:

@if (count($array) > 0)
    {{-- expr --}}
@endif
Answer from Andy.Diaz on Stack Overflow
🌐
ItSolutionstuff
itsolutionstuff.com › post › laravel-array-length-validation-exampleexample.html
Laravel Array Length Validation Example - ItSolutionstuff.com
November 5, 2023 - Sometimes, we require to add validation for array minimum length or maximum length in laravel. user must need to add at least two array value. so Laravel provides default validation rules for array validation. we can use array, min, max, between and size rules to apply for array. You can see the simple solution with the controller code:
Discussions

Array Count - Laravel - Stack Overflow
Have you tried first()? laravel.com/docs/5.6/collections#method-first. In addition, your question is not clear as to what exactly you're trying to achieve ... @OluwatobiSamuelOmisakin i need to update my database with the inputs i get from these arrays. More on stackoverflow.com
🌐 stackoverflow.com
php - Laravel request is an array but not recognized by count() - Stack Overflow
I am passing an array into my controller via axios.post request. I am trying to get the length of the $request array that I am passing to the controller. More on stackoverflow.com
🌐 stackoverflow.com
Laravel eloquent query to get records with array with specified length - Stack Overflow
It seems like this should be pretty simple to find the answer to but apparently not for me. I need to query a count of records where the field called bullets contains an array with a length of 5. H... More on stackoverflow.com
🌐 stackoverflow.com
June 23, 2022
How to use data of a JSON object output from controller in blade file?
To do it in the controller first you should decode the data using json_decode to an associative array, then iterate the data property. It should look like this: $json = PageResult::make($result->answers); $decoded = json_decode($json, true); // true to convert to associative array $data = $decoded['data'] foreach ($data as $array) { $section=$array['section'] ... } Finally, store that data in an array and use it as you will. Another solution is to pass the decoded object in the blade view and use it there. Something like this: return view('my-view, ['data' => json_decode($json, true)] Hope this helps More on reddit.com
🌐 r/laravel
7
1
August 22, 2020
🌐
DevOps Support
devopssupport.in › blog › laravel-array-length-validation
Laravel Array Length Validation – DevOps Support
September 30, 2023 - For instance, to ensure that the ‘users’ array contains no more than three elements, use the validation rule like this. ... Sometimes, you may require an array to have a length within a specific range. Laravel’s between rule is the perfect tool for this job.
🌐
Devnote
devnote.in › home › blog › laravel array length validation
Laravel Array Length Validation - Devnote
November 24, 2025 - Laravel’s validation system is powerful and clean. Instead of writing manual checks like count($array) < 2, you simply add validation rules to your form requests or controllers.
🌐
DevOps Consulting
devopsconsulting.in › blog › array-length-validation-in-laravel
Array Length Validation in Laravel - DevOps Consulting
July 25, 2023 - In Laravel, we occasionally need ... maximum length of an array. A minimum of two array values must be added by the user. Laravel therefore offers default array validation rules. array, min, max, between, and size rules can all be used to apply to an array. ... When you have to validate that an array contains at least three, but not more than ten users, you can apply the between rule: ... <?php namespace App\Http\Controllers; use ...
🌐
Osvod
osvod.com.ua › putting-two › array-length-in-laravel-controller
array length in laravel controller
July 31, 2023 - Find centralized, trusted content and collaborate around the technologies you use most. As mentioned above, the collect helper returns a new Illuminate&#92;Support\Collection instance for the given array. Example 1 Str::length method in laravel Controller stubs may be customized using stub publishing.
🌐
Arievisser
arievisser.com › blog › validating-array-lengths-in-laravel
Validating Array Lengths in Laravel | Arie Visser
December 15, 2019 - One of the cool things of Laravel's validation rules, is that you can apply certain rules to different data types. When checking the minimum and maximum size of an array, you can use the min, max, between, and size rules, which you can also apply to strings and numerics.
🌐
Laracasts
laracasts.com › discuss › channels › laravel › how-to-get-array-count
how to get array count
$idCount = count($array); Like Reply · Snapey · 7 years ago · Level 122 · ReplyReport Spam · 3 year old thread · BASIC PHP SKILLS REQUIRED · Like Reply · 1 like · aurelianspodarec · 4 years ago · Level 7 · ReplyReport Spam · @Snapey Nothing to do with basic PHP. I was thinking that there would be a special Laravel function to get the count instead.
Find elsewhere
🌐
W3Schools
w3schools.com › php › func_array_sizeof.asp
PHP sizeof() Function
affected_rows autocommit change_user character_set_name close commit connect connect_errno connect_error data_seek debug dump_debug_info errno error error_list fetch_all fetch_array fetch_assoc fetch_field fetch_field_direct fetch_fields fetch_lengths fetch_object fetch_row field_count field_seek get_charset get_client_info get_client_stats get_client_version get_connection_stats get_host_info get_proto_info get_server_info get_server_version info init insert_id kill more_results multi_query next_result options ping poll prepare query real_connect real_escape_string real_query reap_async_query refresh rollback select_db set_charset set_local_infile_handler sqlstate ssl_set stat stmt_init thread_id thread_safe use_result warning_count PHP Network
🌐
ItSolutionstuff
itsolutionstuff.com › post › how-to-find-array-length-in-phpexample.html
How to Find Array Length in PHP? - ItSolutionstuff.com
May 14, 2024 - we will use count() function to get array length in php. so, let's see the simple code of how to get length of array in php. ... I hope it can help you... ... I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com.
🌐
Medium
medium.com › codex › mastering-array-validation-in-laravel-a-deep-dive-0e4cc26b6c4d
Mastering Array Validation in Laravel: A Deep Dive | by Harris Raftopoulos | CodeX | Medium
August 16, 2024 - Array validation can be combined with other Laravel validation rules: 'tags' => 'required|array|min:1|max:5', 'tags.*' => 'required|string|distinct|min:2|max:20', ... Each tag is a unique string between 2 and 20 characters.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-find-array-length-in-php
How to Find Array Length in PHP
February 13, 2024 - Your All-in-One Learning Portal. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
🌐
The Coding Dev
thecodingdev.com › home › array length › laravel validator for array length
Laravel Validator for Array Length - The Coding Dev
May 24, 2023 - In this blog post, We are going to learn about validation rules for Array length. This is useful for some of the programs which are very s...
🌐
Carmatec
carmatec.com › home › how to get the length of an array in php: complete guide
How to Get the Length of an Array in PHP: Complete Guide
September 28, 2024 - Learn how to get the length of an array in PHP using the count() function, with practical examples to enhance your coding skills.