366 solutions found in php-dev
Page 14 of 19votes
I'd like to check if two arrays are equal. I mean: same size, same index, same values. How can I do that? Using `!==` as suggested by a user, I expect th...
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 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
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
If I define an array in PHP such as (I don't define its size): <!-- language: lang-php --> $cart = array(); Do I simply add elements to i...
votes
Is there a function to make a copy of a PHP array to another? I have been burned a few times trying to copy PHP arrays. I want to copy an array defined insid...
votes
Does anyone have a `T_PAAMAYIM_NEKUDOTAYIM`?
votes
Quite often I will try and run a PHP script and just get a blank screen back. No error message; just an empty screen. The cause might have been a simple syntax...