0

i have array like this

$data = array(
array('name'=>'Matemathic','SKS'=>5),
array('name'=>'History','SKS'=>2),
array('name'=>'English','SKS'=>3)
);

i want to search where name 'History' and get SKS value

9
  • 1
    I guess this PHP code, what is the relationship with sql? Commented Sep 2, 2018 at 7:56
  • oh im sorry, this array im get from sql, but in php i want search value in array Commented Sep 2, 2018 at 7:58
  • You should handle this in SQL using a query with a where clause. Commented Sep 2, 2018 at 7:59
  • any php code to find array ? ijust find a problem without duplicat sql, with where and without where to find that value Commented Sep 2, 2018 at 8:01
  • 2
    What have you tried so far? Commented Sep 2, 2018 at 8:02

1 Answer 1

0
$data = array(
array('name'=>'Matemathic','SKS'=>5),
array('name'=>'History','SKS'=>2),
array('name'=>'English','SKS'=>3)
);

foreach($data as $i) {
    if ($i['name'] == 'History') {
        echo $i['SKS'];
        break;
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.