Category : arrays

I need to retrieve the first key in array searched with array_search. If I try this: $a=array("Value3"=>"red","Value2"=>"green","Value3"=>"pink","Value4"=>"blue"); echo array_search("red",$a); I receive a empty echo but expected: Value3 If I try this: $a=array("Value3"=>"red","Value2"=>"green","Value3"=>"pink","Value4"=>"blue"); echo array_search("pink",$a); I receive: Value3 Can someone help me? Thank you Sourc..

Read more

I have an array like : array(2) { [0]=> array(2) { [0]=> string(2) "31" [1]=> string(15) "Bangunan Gudang" } [1]=> array(2) { [0]=> string(2) "59" [1]=> string(11) "Ruang Gardu" } } I want to result like this array(2) { [0]=> string(2) "31" [1]=> string(2) "59" } thanks… Sourc..

Read more

$option_mark=array(); $option_mark[1] = $_POST[‘choice1_marks’]; $option_mark[2] = $_POST[‘choice2_marks’]; $option_mark[3] = $_POST[‘choice3_marks’]; $option_mark[4] = $_POST[‘choice4_marks’]; This is my array whose values i want to store in mysql inside an if loop. if($result){ foreach($choice as $option => $value){ if($value != ""){ if($correct_choice == $option){ $is_correct = 1; }else{ $is_correct = 0; } //Second Query for Choices Table $query ..

Read more

I am getting array in foreach loop,There are two keys "sequence"(unique,not repeated) and "asset_type"(can duplicate/same) And i want to run loop with every "sequence" with every "asset_type",i want to execute my loop like following way so i can check every "sequence" with every "asset_type" sequence asset_type 1 1 1 2 1 n (last asset_type) … ..

Read more