Here is my array:
Array ( [0] => Array ( [same_key] => 1000 ) [1] => Array ( [same_key] => 1001 ) [2] => Array ( [same_key] => 1002 ) [3] => Array ( [same_key] => 1003 ) )
I want to get the following without using a foreach loop. Is it possible?
Array ( [0] => 1000 [1] => 1001 [2] => 1002 [3] => 1003 )
Any tips?
The following will do the trick
$myArray = Array ( 0 => Array ( 'adfadf'=> 1000 ), 1 => Array ( 'adfadf' => 1001 ), 2 => Array ( 'adfadf' => 1002 ), 3 => Array ( 'adfadf' => 1003 ) ); $myArray = array_map('current', $myArray));
you can do this with $array = array_map('current', $array);
$array = array_map('current', $array);
living example
Output
Source: https://habr.com/ru/post/1436208/More articles:Error CS0246: type name or namespace `HtmlAgilityPack 'not found - c #https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1436204/initializing-data-structures-to-constant-values-with-mixed-data-types&usg=ALkJrhinnJ2j_hwEwk3_LnG_r4wgWW2EWgHow to list only properties / methods of JavaScript objects added at runtime? - javascriptMultiple event handlers for the same event in VB.NET - event-handlingjava.util.Map.put (key, value) - what if the value is equal to the existing value? - javaHow can I profile Python functions in turn in the Google App Engine? - profilingHow does the HashMap make sure the index calculated using the hashcode key is within the available range? - javaPython Xlib - Xlib.error.BadAccess on root.display.next_event () - pythonInvalid method SvgAnimatedString indexOf - javascriptRunning a simple cascading application in local mode - javaAll Articles