Skip to content

Add class to loop iteration php

I’m stumped here. I have six CSS classes that I want to dynamically apply to my loop. grid1,grid2,grid3,grid4,grid5,grid6 How do I apply that when I run on the 7th iteration it would apply “grid1” and so and so forth? What would be the best way? Answer The easiest and imo cleanest way to ach…

Remove the comma and number of a string

I tried to find a solution, but no luck so far. I need to remove the comma and third number (,1482.36 / ,73.50 / ,-472.15 / ,472.15) of each ‘block’ in a given string like the example bellow: Any clues of how I could do it in PHP? Thanks Answer You will need to use preg_split actually to split the

Laravel validate() method returns index html page when false

I’m building my first laravel API and when I try to validate some mock form data using Postman with POST method, the application returns to me the HTML of the index page and status 200. Here is my code The application returns the object that was inserted in the database if the validation was successful …

Relationship eloquent in laravel?

In user: In post: I handle in controller: Then I get an array and the result returned is exactly what I need. But when I query this way because I need to get a lot of data, the result is an empty array. What did I do wrong? In UserController.php: Please give me any comments. Answer You have to select

Cannot inject foreign repository into my controller

I’ve got a problem concerning a plugin I’m writing for Typo3. I want to have access to a repository (and the content of that) of a plugin in a different plugin. Like importing the stuff from one plugin to another. What I tried was using @inject in my controller, but the result is null. And my acti…