All Questions
72,365 questions
-1
votes
2
answers
32
views
Converting mongodb node codes to php [closed]
my node codes work, but when I want to write it in PHP, it does not work. can you help?
node code mongo sh works without any problems
db.mevcutlot.aggregate([{$match: {_id: {$ne: null}}},
{ $...
1
vote
0
answers
16
views
Meta data omitted when adding data object to array - Laravel
I have the following function in Laravel :
public static function foo($data)
{
if (gettype($data) === 'array')
$data = (object)$data;
return $data;
}
That prints the following data:
{...
1
vote
3
answers
50
views
Add key => value pair to existing index of PHP array
I have this PHP array:-
$tblData[] = array(
"Orange" => "Healthy",
"Apple" => "Good",
"Pizza" => "Bad",
);
This is the ...
3
votes
1
answer
108
views
Callable Arrays in PHP since 7.0 [duplicate]
I noticed that since PHP 7.0, I can use syntax like this:
<?php
["a", "b"]();
When I run it, I encounter the following error:
Fatal error: Uncaught Error: Class 'a' not found ...
-2
votes
4
answers
123
views
How to iterate multidimensional array data and sum some values to return a grouped array
What's the simplest way and uses less computing power to check if a multidimensional array has some equal values in the sub keys and, if is in this way, make the sum of that?
Look at the input. It's ...
1
vote
2
answers
42
views
Incosistent access of the array entries of an indexed array [closed]
I'm not sure how to describe or even title this issue but I feel the psuedo code explains it well. I have a multidimensional array called $data (4 levels) and some php code as follows:
$data = [
...
2
votes
0
answers
49
views
Why does count() with COUNT_RECURSIVE returns incorrect result for my 2-d array? [duplicate]
I have filled a 2 dimensional array with the following code
$chessboard = array(
array('r','n','b','q','k','b','n','r'),
array('p','p','p','p','p','p','p','p'),
array(' ',' ',' ',' ',' ...
0
votes
1
answer
62
views
Why hashtable (array implementation) compaction does not kick in in PHP?
I am making a big PHP array and then remove most of the beginning of it. As we know it won't free the memory only mark removed items as Undef, as explained by Nikita here. However when I put more ...
1
vote
2
answers
79
views
Distribute total amount to a flat array of "container" elements with predefined limits
I'm trying to split items evenly through groups with a max on each group.
I have a function which receives a $groups array which declares the maximum capacity of each "group" and an $items ...
-1
votes
1
answer
59
views
How to parse an ini-like string into an array
I'm working on a song database application with an existing database. In the editor the songs are laid out like this in the contents column:
[chorus]
And all will surely agree,
There's nothing like ...
0
votes
0
answers
32
views
php Ajax $_FILES empty [duplicate]
I can't find how to get my ajax function to see the $_FILES array. This is a very common problem and I have read through many posts. Some of those say to load the form data. I tried (the commented out ...
0
votes
1
answer
26
views
PHP json_decode multiple arrays or array in array to database [duplicate]
I have json from another system, how to store in oracle database? I dont mind if using while or for or what ever, i only hope can store in database in 4 rows without null line as null line provided by ...
0
votes
0
answers
21
views
How to to change the value for a key in an array in PHP? [duplicate]
<?php
$orderTracking = $order['ItemDetails'][0]['TrackingDetails'] ?? [];
$tracking = []; //Declaration of the array
foreach ($orderTracking as $track) {
if (is_array($track)) {...
0
votes
0
answers
14
views
Sort PHP array by a key value of each item's value [duplicate]
How would one sort a php array in order of a particular key value pair inside the next level down.
Input array
$sizes = [
'small' => ['name' => "Small", 'x' => 300],
'x-small' =&...
-2
votes
0
answers
21
views
Updating to PHP 8 | Attempt to read property on null | Undefined array key 0 [duplicate]
Trying to update very obsolete code from an old Wordpress plugin.
Getting these 2 errors on this line
Attempt to read property 'quiz_desc' on null
Undefined array key 0
Can anyone please help me with ...