Driver code
$ k = 2 ; $ arr = array ( 2 , 4 , 1 , 3 , 1 ) ; $ n = count ( $ arr ) ; echo " Total ▁ pairs ▁ for ▁ k ▁ = ▁ " , $ k , " ▁ are ▁ " , countPairsWithKDiff ( $ arr , $ n , $ k ) , " STRNEWLINE " ; ? >