Backreference in PHP I have a Content Type Courses  &amp; a User Role Student

In the student I used EntityReference to refer to a number of courses.

Is it possible to get a list of all the students that have a particular course referenced to them, in PHP?

Right now I'm only accustomed in getting a value from a field in a content type like this:

$user_surname = $profile_info['student']-&gt;field_surname['und'][0]['value'];




PS I think this has to do with back-reference,which is a module I already installed.
You could do this with views (without PHP), but if you want to use PHP you should check out Entity Field Query

You will have to do something like this:

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'user')
  -&gt;propertyCondition('status', NODE_PUBLISHED)
  -&gt;fieldCondition('your_field_course', 'target_id', $nid, '=')
  -&gt;addMetaData('account', user_load(1)); // Run the query as user 1.
$result = $query-&gt;execute();
if (isset($result['user'])) {
  $uids = array_keys($result['user']);
  $users = entity_load('user', $uids);
}