Category : string

In my laravel application, I have a form to register new users. In that form, I have a field to input user birthday. Even though I’m taking user input dates in d/m/Y format, from my controller I’m converting them into Y-m-d before saving them to the DB. if(!empty($request->date_of_birth)){ $date = str_replace(‘/’, ‘-‘, $request->date_of_birth); $new_bday=date("Y-m-d", strtotime($date) ..

Read more

I’m working on a websocket server, the clients are known by their tokens, the tokens are 100 characters long and unique, which makes me worried if a lot of users get connected that can use a lot of ram, since on websocket you need to save them in an array or something in the memory. ..

Read more

Using PHP, I want to: Return ONLY 5, known, values from a string containing a comma separated list of text values Example String: $a = tuna, ham, car, sled, show, nut, train, bike, house Desired return: $a = ham, sled, show, nut, bike What is the most efficient way to achieve this result? Source: Ask ..

Read more

sorry for a noob question but I am wondering if you could format strings in php with comma or dashes, something like this: Ex. #1 Sample Input: 123456789 Formatted Output: 123,456,789 or 123-456-789 Ex. #2 Sample Input: 0123456789 Formatted Output: 012,3456,789 or 012-3456-789 If anyone could help me out, that would be appreciated. Source: Ask ..

Read more