Skip to content

Tag: php

PHP – fgetcsv loop for get data from csv file column by column

I have a CSV file with 31 columns and 24 rows. I need with fgetcsv (or maybe another solution) to pass in the CSV and get data column by column. I have one solution: The for loop is working but $data[$col] only gets data from the first column of the CSV, it doesn’t get data from $data[$col] when $col is

Laravel container and shared instances

I am wondering how Laravel differentiates between singletons(shared instances) and concrete implementations that might be overwritten inside the container. The container has a bind method that looks like this: It also has a singleton method that calls this function but with the $shared argument always being t…

PHP 7 inconsistently throwing errors for division by zero

I am currently trying to understand the behavior of the new error handling in PHP 7. In the PHP Documentation for DivisionByZeroError, it states: DivisionByZeroError is thrown when an attempt is made to divide a number by zero. Fair enough, but it does not throw the DivisionByZeroError when the / operator is …

Cookie aren’t saved

I need to save a cookie, I’m trying to do this with setcookie function, I did: in the browser there is no cookie saved, why? Answer Some of your settings are wrong. I’ve corrected can you try?

Group by query in in laravel 5.3

I have fired this query: but I got the following error: PDOException in Connection.php line 332: SQLSTATE[42000]: Syntax error or access violation 1055 ‘baseproject_new.articles.user_id’ isn’t in GROUP BY When run the query in mysql I got the result, but when I run the page I got the error. …