i have a table named mobile in which all the mobile data is contained which have more then 7000 records now i want to display in json format but some how records are not showing here is my code kindly check .. table Answer The problem with JSON_ENCODE in PHP is, it tends to add double quotes and escaping sequ…
Tag: php
How to validate an input field if value is not null in Laravel
I am trying to create and update users with laravel 5.4 This is the validation added for create user. It works. On update the password field is not required. But validate the min:6 and confirmed rule if the password field is not null. Tried with sometimes.. but not working.. Answer try using nullable as a rul…
Accessing Laravel .env variables in blade
I am trying to get some API keys which I have stored in my .env file to use in the blade javascript. I have added two keys like: In blade I need to use the Google Maps API and OverheidIO API key. I have tried getting one of the default .env variables just in case I have formatted the custom
Regex for 24 hour time
I have found a working expression for accepting only 24 hour time, but my problem is it will accept things before and after such as characters awf23:59fawf 23:59gfes 123:59 Are all accepted, I want to stop allowing this and only accept HH:MM within my statement: if (preg_match_all(“~((2[0-3]|[01][1-9]|1…
PHP MySQL Error echo insert into values printing on screen
I am learning PHP MYSql and faced an error while writing a marks submission program. When i run the program in chrome, the table is coming ok but neither the values are inserting in the MySQL table nor the redirection to different webpage taking place. You will understand it more clearly in the code and scree…
Use array_merge_recursive for unknown number of arrays
I have a PHP script where I get a random number of arrays nested inside an array and need to merge them using array_merge_recursive. Given the number of nested arrays is always variable, is there a …
preventing abuse of API service usage
I am planning on using Laravel in my next web project, for the backend. Using the Laravel’s built-in functionality I will build an API service. So my main concern now – is about the security of such service. Laravel’s API throttling middleware seems to be an easy to use solution, but it does…
How to remove spaces from my php
When I run my php code it shows the content perfectly, but there’s a space after start and before stop. How do I remove all spaces? I thought that’s what I was doing with trim? Answer You should trim all the whitespace characters, like this:
fill in the multidimensional array with missing keys
I have the following multidimensional array. I had to create keys the way it looks to group them accordingly. However, I need all the subarrays to have the same keys. Missing ones should be filled with a value of 0. The final array should be like below so that all subarrays have equal length. Answer You need …
Laravel 5.4 required if validation issue
I have 2 fields, accepts_usd and price_usd. For price usd I have a validation rule: And for accepts_usd: When I want to store data if I set accepts_usd to false it still asks for price_usd. whats the issue here? What am I doing wrong? Answer From laravel docs: required_if:anotherfield,value,… The field …