PHP create_function with nested arrays
问题 I need to use create_function because the server the application is running on has an outdated version of PHP. The issue is that the items I pass into usort are arrays and I need to sort by a value within the array: $sort_dist = create_function( '$a, $b', " if( $a['order-dir'] == 'asc' ) { return $a['distance'] > $b['distance']; } else { return $a['distance'] < $b['distance']; }" ); usort( $items, $sort_dist ); Gives an error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T