Search code examples
phpphpstorm

How to reformat code associative array in new line in PhpStorm?


Simply, I have now code like following:

$myArray = array( 'restaurant_id' => $res_id, 'menu_id' => $menu_id, 'food_id' => $foods_id);

After reformatting my array is show in one line. If array is long it is time wasting to navigate right side of the editor.

I want to reformat all of my code array snippet like following:

$myArray = array(
   'restaurant_id' => $res_id, 
   'menu_id' => $menu_id, 
   'food_id' => $foods_id);

How can I achieve that?


Solution

  • Finally! I found the problem. In File | Settings | Editor | Code Style | Wrapping and Braces | Array Initializer Option was do not wrap. For that reformat code was not working as expected.