2108 solutions found
Page 23 of 106votes
How to find number of days between two dates using PHP?
votes
What's the correct way to round a PHP string to two decimal places? $number = "520"; // It's a string from a database $formatted...
votes
I am calling my Java webservice (POST request) via Postman in the following manner which works perfectly fine (i.e. I can see my records getting inserted into t...
votes
I have a variable in PHP, and I need its value in my JavaScript code. How can I get my variable from PHP to JavaScript? I have code that looks like this: ``...
votes
How can I **strip** / **remove** all **spaces** of a **string** in PHP? I have a **string** like `$string = "this is my string";` The output sho...
votes
In PHP, you can declare constants in two ways: 1. With `define` keyword ```PHP define('FOO', 1); ``` 2. Using `const` keyword...
votes
Everyone runs into syntax errors. Even experienced programmers make typos. For newcomers, it's just part of the learning process. However, it's often ea...
votes
What are the differences between `die()` and `exit()` functions in PHP? I think both have the same functionality, but I doubt there is something different in...
votes
I've run into a few cases with WordPress installs with [Bluehost][1] where I've encountered errors with my WordPress theme because the uploads folder `w...
votes
I have a variable which contains the value `1234567`. I would like it to contain exactly 8 digits, i.e. `01234567`. Is there a PHP function for that?
votes
Let's say I have code like this: $dbh = new PDO("blahblah"); $stmt = $dbh->prepare('SELECT * FROM users where username =...
votes
I get a strange error using `json_decode()`. It decodes the data correctly (I saw it using `print_r`), but when I try to access to information inside the array...
votes
I installed node using homebrew (Mojave), afterwards php stoped working and if I try to run `php -v` I get this error: php -v dyld: Library not load...
votes
I'm trying to check if a string starts with `http`. How can I do this check? $string1 = 'google.com'; $string2 = 'http://www.google....
votes
I am trying to install a specific version of a package using Composer. I tried `composer install` and `composer require` but they are installing the latest vers...
votes
What is the correct way to remove a package from Laravel using PHP Composer? So far I've tried: 1. Remove declaration from file *composer.json* (in th...
votes
How can I sort this array of objects by one of its fields, like `name` or `count`? Array ( [0] => stdClass Object (...
votes
I'd like to capture the output of [`var_dump`][1] to a string. The PHP documentation says; > As with anything that outputs its result directly to t...
votes
I need to store a multi-dimensional associative array of data in a flat file for caching purposes. I might occasionally come across the need to convert it to JS...
votes
Is it possible to find the `foreach` index? in a `for` loop as follows: for ($i = 0; $i < 10; ++$i) { echo $i . ' '; } `$i`...