php: why is $row[0] not returning anything?

I am converting all my php scripts due to moving to a new server. I am stumped as to why $row[0] is not working. I am correctly getting $row populated as an array, and if I run a foreach on it, I get all the values populated just fine. But if, instead, I try to… Read More php: why is $row[0] not returning anything?

Creating an associative array in PHP

I am a beginner to Programming; I am stuck while creating an associative array from an existing associative array <?php $arr = array( array( "question"=>"I get irritated easily.", "answer"=>"1" ), array( "question"=>"I spend time reflecting on things.", "answer"=>"1" ), array( "question"=>"I am quiet around strangers.", "answer"=>"1" ), array( "question"=>"I make people feel at ease.", "answer"=>"1"… Read More Creating an associative array in PHP

Map two associative arrays which have different sizes/keys

I want to merge 2 arrays together but I want it in a specific way. The first array are the dates I want to filter with the second array dates. $first = [ ‘2022-10-23’ => ‘2022-10-23’, ‘2022-10-24’ => ‘2022-10-24’, ‘2022-10-25’ => ‘2022-10-25’, ‘2022-10-26’ => ‘2022-10-26’, ‘2022-10-27’ => ‘2022-10-27’, ‘2022-10-28’ => ‘2022-10-28’, ‘2022-10-29’ => ‘2022-10-29’ ];… Read More Map two associative arrays which have different sizes/keys

How can I convert PHP Associative Arrays to JSON?

I’m trying to convert a small JSON to PHP Associative Arrays, but I’m missing a simple thing. Please check the following: JSON to convert: $data = ‘{ "intent": "CAPTURE", "purchase_units": [{ "amount": { "currency_code": "EUR", "value": "211.00", } }], }’; My wrong PHP Associative Arrays: $data = array( "intent" => "CAPTURE", "purchase_units" => array( "amount"… Read More How can I convert PHP Associative Arrays to JSON?

How can I create an array of variables based on an associative array's value in PHP?

Given the following array ( 0 => array( ‘orders_messaging_info_id’ => ‘1’, ‘column_name’ => ‘message_route’, ‘column_info’ => ‘internal’, ), 1 => array( ‘orders_messaging_info_id’ => ‘2’, ‘column_name’ => ‘message_route’, ‘column_info’ => ‘external’, ), 2 => array( ‘orders_messaging_info_id’ => ‘3’, ‘column_name’ => ‘message_type’, ‘column_info’ => ‘SMS’, ), 3 => array( ‘orders_messaging_info_id’ => ‘4’, ‘column_name’ => ‘message_type’, ‘column_info’ =>… Read More How can I create an array of variables based on an associative array's value in PHP?

How to check given value present in nested array in PHP?

I am very new to the PHP, i want to check the value is present inside the associative array,please help me to acheive this thing. public $array=[ ‘id’,’name’, ‘value.details’=>[‘type’=>’myFunction’] ]; foreach($array as $key=>$condition){ if(in_array(‘myFunction’,$array)){ //My logic } } >Solution : if you know the keys: if($array[‘value.details’][‘type’] === ‘myFunction’) { } if you walk through your… Read More How to check given value present in nested array in PHP?

Parse and modify an array in Javascript

I am working in Javascript with a .dat file with different data about English Soccer teams. I was able to obtain a Json that I transform in this array: [{"team":"Arsenal","f":"79","a":"36"}, {"team":"Liverpool","f":"67","a":"30"}, {"team":"Manchester_U","f":"87","a":"45"}, {"team":"Newcastle","f":"74","a":"52"}, {"team":"Leeds","f":"53","a":"37"}, {"team":"Chelsea","f":"66","a":"38"}, {"team":"West_Ham","f":"48","a":"57"}, {"team":"Aston_Villa","f":"46","a":"47"}, {"team":"Tottenham","f":"49","a":"53"}, {"team":"Blackburn","f":"55","a":"51"}, {"team":"Southampton","f":"46","a":"54"}, {"team":"Middlesbrough","f":"35","a":"47"}, {"team":"Fulham","f":"36","a":"44"}, {"team":"Charlton","f":"38","a":"49"}, {"team":"Everton","f":"45","a":"57"}, {"team":"Bolton","f":"44","a":"62"}, {"team":"Sunderland","f":"29","a":"51"}, {"team":"Ipswich","f":"41","a":"64"}, {"team":"Derby","f":"33","a":"63"}, {"team":"Leicester","f":"30","a":"64"}] This array contain the name of… Read More Parse and modify an array in Javascript

Create an array from an associative array using one of its value in a key value pair

I’ve a following associative array named $data. Here is some same key value pairs Array ( [0] => Array ( [id] => 1 [config_id] => 31 [language] => "English" ) [1] => Array ( [id] => 2 [config_id] => 33 [language] => "English" ) [2] => Array ( id] => 3 [config_id] => 32 [language]… Read More Create an array from an associative array using one of its value in a key value pair

How to create multidimensional array from php post?

how to create multidimensional & associative array from php post? $html .= ‘<td><input id="location" name="location[‘.$i.’]" type="text" class="form-control form-control-sm form-control-solid" placeholder="result data (kosongkan jika tidak diperlukan)" value=""/></td>’; $html .= ‘<td><input id="msg" name="msg[‘.$i.’]" type="text" class="form-control form-control-sm form-control-solid" value="’ . htmlspecialchars($key) . ‘"/></td>’; $html .= ‘<td><input id="order_id" name="order_id[‘.$i.’]" type="text" class="form-control form-control-sm form-control-solid" value="’ . htmlspecialchars($value) . ‘"/></td>’; i… Read More How to create multidimensional array from php post?