User submissions are the sole responsibility of contributors, with TuteeHUB disclaiming liability for accuracy, copyrights, or consequences of use; content is for informational purposes only and not professional advice.
My question may sound confusing to some people. But in fact it's a quite simple one. Let me clear you the scenario. I've an array titled $test_result_data as follows:
Array([0]=>Array([test_pack_id]=>8ed32f6479a0169db3531d3366996d35[test_pack_name]=> CPT FreeSamples[test_pack_desc]=>Thispackage contains a free sample test of 30 minutes containing 30 questions from-Fundamentals of accounting,MercantileLaw,GeneralEconomicsandQuantitativeAptitude.Thisis perfect to discover the beauty of online exam preparation.[test_pack_type_id]=>7[test_pack_image]=>[test_pack_validity_year]=>0[test_pack_validity_month]=>0[test_pack_validity_days]=>3[test_pack_plan]=> free
[test_pack_price]=>0.00[test_pack_no_tests]=>0[test_pack_publish]=> yes
[test_pack_code]=>[test_pack_sold]=>22[test_pack_created_staff_id]=> ff8d4a5ea6bf11dce105aa2fa7b959b8
[test_pack_updated_staff_id]=> ff8d4a5ea6bf11dce105aa2fa7b959b8
[test_pack_created_date]=>1337014879[test_pack_updated_date]=>1376886700[test_pack_purchase_date]=>1364454118[test_details]=>Array([0]=>Array([test_id]=>159[test_name]=> CPT SampleTest[test_max_score]=>120.000[test_no_questions]=>30[test_attempt]=>15[test_not_attempt]=>7[avg_test_user_time_used]=>00:04:39Hr[top_score]=>46.00[avg_score]=>3[lower_score]=>0.00)))[1]=>Array([test_pack_id]=>84880f321fc957f9b28b702d5a43f57b[test_pack_name]=> CPT GeneralEconomics[test_pack_desc]=>ThisPackage contains <b>16 chapterwise testlets
function packed_element($id){foreach($test_result_data as $k => $v)if($v->test_pack_id === $id)return $v;}
But if you can manage the code that generate the array I suggest you to simply use dictionary array over simple one, that have your id as key. So you can referrer to your element directly. For example you can generate an array like this:
Array([8ed32f6479a0169db3531d3366996d35]=>Array([test_pack_id]=>8ed32f6479a0169db3531d3366996d35[test_pack_name]=> CPT FreeSamples[test_pack_desc]=>Thispackage contains a free sample test of 30 minutes containing 30 questions from-Fundamentals of accounting,MercantileLaw,GeneralEconomicsandQuantitativeAptitude.Thisis perfect to discover the beauty of online exam preparation.[test_pack_type_id]=>7[test_pack_image]=>[test_pack_validity_year]=>0[test_pack_validity_month]=>0[test_pack_validity_days]=>3[test_pack_plan]=> free
[test_pack_price]=>0.00[test_pack_no_tests]=>0[test_pack_publish]=> yes
[test_pack_code]=>[test_pack_sold]=>22[test_pack_created_staff_id]=> ff8d4a5ea6bf11dce105aa2fa7b959b8
[test_pack_updated_staff_id]=> ff8d4a5ea6bf11dce105aa2fa7b959b8
[test_pack_created_date]=>1337014879[test_pack_updated_date]=>1376886700[test_pack_purchase_date]=>1364454118[test_details]=>Array([0]=>Array([test_id]=>159[test_name]=> CPT SampleTest[test_max_score]=>120.000[test_no_questions]=>30[test_attempt]=>15[test_not_attempt]=>7[avg_test_user_time_used]=>00:04:39Hr[top_score]=>46.00[avg_score]=>3[lower_score]=>0.00))
No matter what stage you're at in your education or career, TuteeHUB will help you reach the next level that
you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice
sessions to improve your knowledge and scores.
manpreet
Best Answer
3 years ago
My question may sound confusing to some people. But in fact it's a quite simple one. Let me clear you the scenario. I've an array titled
$test_result_dataas follows: