Hi all,

I have a multidimentional array that i need converting to a single array on the fly.
to do this i use the following function.

I need it to be changed to return the key name rather than setting it to a value

function array_values_recursive($ary)  {

    $lst = array();
		foreach( array_keys($ary) as $k ) {
	
		$v = $ary[$k];
			if (is_scalar($v)) {
		
			$lst[] = $v;
		
			} elseif (is_array($v)) {
		
			$lst = array_merge($lst,array_values_recursive($v));
		
			}
	
		}

    return $lst;

}

Can you provide an example of the array you have and that you want at the end? Just few entries to get an idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.