2108 solutions found
Page 18 of 106votes
Is there a way of doing something like this: $test_array = array( "first_key" => "first_value", "second_ke...
votes
How can I merge two arrays (one with string => value pairs and another with int => value pairs) while keeping the string/int keys? None of them will ever...
votes
How can I get the first n characters of a string in PHP? What's the fastest way to trim a string to a specific number of characters, and append '...'...
votes
After using PHP for a while now, I've noticed that not all built-in PHP functions are as fast as expected. Consider these two possible implementations of a...
votes
Assume you have a GraphQL type and it includes many fields. How to query all the fields without writing down a long query that includes the names of all the fi...
votes
What is the "less code needed" way to get parameters from a URL query string which is formatted like the following? > www.mysite.com/category/su...
votes
I am just getting a grasp on the MVC framework and I often wonder how much code should go in the model. I tend to have a data access class that has methods like...
votes
Ok, I know all about [`array_pop()`][1], but that deletes the last element. How to get the last element of an array without deleting it? Here's a bon...
votes
<?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from =...
votes
I have this code: <script type="text/javascript"> var foo = 'bar'; <?php file_put_contents('...
votes
I am trying to convert a date from `yyyy-mm-dd` to `dd-mm-yyyy` (but not in SQL); however I don't know how the date function requires a timestamp, and I can...
votes
I'm trying to connect to a Tor hidden service using the following PHP code: $url = 'http://jhiwjjlqpyawmpjx.onion/' $ch = curl_init();...
votes
How do I convert the value of a PHP variable to string? I was looking for something better than concatenating with an empty string: $myText = $myVar ....
votes
I need a really, really fast method of checking if a string is JSON or not. I feel like this is not the best way: function isJson($string) { ret...
votes
I was diving into Symfony framework (version 4) code and found this piece of code: $env = $_SERVER['APP_ENV'] ?? 'dev'; I'm not su...
votes
Here's the information [according to the official documentation][1]: > There are four different pairs of > opening and closing tags which can be...
votes
I have a PHP file that is sometimes called from a page that has started a session and sometimes from a page that doesn't have session started. Therefore whe...
votes
I can't figure out how to add a new column to my existing database table using the Laravel framework. I tried to edit the migration file using... <...
votes
I wish to get the file extension of an image I am uploading, but I just get an array back. $userfile_name = $_FILES['image']['name'];...
votes
How can I convert an array like this to an object? ``` [128] => Array ( [status] => "Figure A. Facebook's horizontal scrollba...