In that case take a look at where such is implemented in php-src, dns_get_record() is an example despite the slightly clouded code: http://git.php.net/?p=php-src.git;a=blob;f=ext/standard/dns.c;h=f92015eee90d3e93a801e93d6381d89923825166;hb=refs/heads/master#l1011
dns_get_record (as opposed to dns_get_mx you actually linked to) would be a bad example because its reference parameters are broken since php 7 (see https://bugs.php.net/bug.php?id=73594). dns_get_mx() is ok though.