I'd like to implement a for loop using the $array as $element syntax in an anonymous function
Is this possible? I can't use forEach as the $array is actually an object, and forEach doesn't copy the object as it would with an array
I'm using laravel so I'm trying to write a blade directive like forEach but in a way that it makes a copy of the object.
something like:
Blade::directive('safeForEach', function ($array as $el){
return '<?php for ($i = 0; $i < count($array); $i++){ ?>';
});
where after @safeForEach is called, I can use each $el.
Blade::directive('endSafeForEach', function (){
return '<?php { ?>';
});
Any ideas please? I've tried to find the source for the blade directive but can't find it. Thanks