Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
0 votes
2 answers
15 views

PHP variable from mysql query in form, when null

I have an html form used to edit a record in a mysql table. In the case of editing, I prefill the form with the current values for the record as returned by the query, as below: <INPUT TYPE="...
rdel's user avatar
  • 155
-3 votes
0 answers
30 views

Get sum of values in multi array [duplicate]

I have an array with different keys, and I am interested in the sum of the values of only the ones that start (or contain) "MT". $json = file_get_contents($path2); //echo $json.'<br&...
Amphata's user avatar
  • 27
0 votes
0 answers
49 views

PHP multiple checkbox save values in array like i clicked them

Hello i use a code that i found here but i have a problem. The problem is that the result of all checkboxes are a sorted one. But i want that the sort is like i clicked them. Like a Android Code ...
phpfreund's user avatar
0 votes
0 answers
29 views

How to get particular value in multi dimensional array while have exact key string [duplicate]

$tstr = 'jsonObj["Results"]["Tests"]["child"] '; print_r($$tstr); Warning: Undefined variable $jsonObj["Results"]["Tests"]["child"] How ...
Gnanasekar Boju's user avatar
1 vote
2 answers
67 views

PHP recursive loop to filter out item and subitem based on key, value condition

I'm facing a multi dimenstions array filter problem. Let's say I had more than 3, or 50 levels of arrays inside an array, how can we filter them based on a key, value pair? for Example: $arr = [ ...
Hùng Thái's user avatar
1 vote
1 answer
49 views

how to use string to be key of array in php

I have array that need to call. $array['first_key']['second_key'] = 'value'; $keys = "['first_key']['second_key']"; I want to call it $array.$key that like $array['first_key']['second_key']. ...
Rahmat Hidayat's user avatar
0 votes
1 answer
31 views

CSV backslash create issue while procession file data

I am trying to process a CSV file in which one column contains JSON formatted data. In this JSON data, some fields use backslashes, which creates a problem when mapping fields with their values. Link ...
Siddhart hundare's user avatar
-1 votes
0 answers
20 views

Output an object's value without looping [duplicate]

I'm trying to var_dump the guid value in this object without setting up a foreach loop. I think the ["2"] key is throwing me off. This data is coming from the Toast API. Any help would be ...
Rob Myrick's user avatar
-2 votes
0 answers
20 views

How to find matching words and phrases in two strings with php [closed]

I have two strings. In the spam.php file, $bad_words list looks like this (they can be a word or phrases): $bad_words = " kittens fake driver license real passports buy passports buy driver ...
VitalSigns's user avatar
-1 votes
0 answers
20 views

understanding json_decode data [duplicate]

When I use json_decode and look at the results, I get a list of objects and arrays. I specifically want to retrieve one piece of information, but I'm not sure how to get it. I seem to have a stdClass ...
kenwat's user avatar
  • 1
0 votes
1 answer
72 views

I keep getting this error "Cannot access offset of type string on string" whenever I try to serve dummy data to my Laravel application [closed]

I am trying to serve some data to my view. However, when i try to access the elements in my dummy array, i keep getting an error "Cannot access offset of type string on string". And I don't ...
BARIMA YAW's user avatar
-1 votes
1 answer
72 views

array_filter() returning the entire array instead of just the key value [duplicate]

I am doing a work around with PHP array_filter() function. I am noticing a strange. Let me explain. This is an array $languageDataArray:- $languageDataArray = array( array( 'id' => 1, ...
Saswat's user avatar
  • 12.7k
0 votes
0 answers
57 views

Push entries into a result array from deepest nested loop, but also push an entry when deepest loop is not reached

I am creating an array for an order to then pass this data to stripe, the array has multiple forEach clauses. The issue I am facing is, if the order item(s) does not have menu_options it is not ...
George Richardson's user avatar
-3 votes
0 answers
39 views

How does the 'as' syntax work in foreach? [duplicate]

I am struggling with how the 'as' works in arrays. Also a bit confused on the breakup of the $name and $grade. $studentGrades = [ 'John' => 90, 'Mary' => 94, 'Cindy' => 80 ]; foreach($...
Jakt's user avatar
  • 1
1 vote
1 answer
32 views

Trying to access array offset on value of type bool - PHP 8.1 - Wordpress - Mulivendorx plugin

I get this error when this code is run as a Wordpress code snippet using WP Code plugin. I'm sure it has to do with the code provided by the plugin developer being out of date, not in-line with ...
StevieK's user avatar
  • 31

15 30 50 per page
1
2 3 4 5
4815