Reputation: 1190
I am currently not comprehending arrays in bash *nix. I have worked mainly with php. I have struggled to understand how to loop through multidimensional arrays. From some basic research I see that bash doesn't deal with multidimensional arrays. Is there a work around? How can I replicate the below php to bash?
PHP example
$social_media = array( array( 'seconds' => 15, 'social' => 'Instagram' ), array( 'seconds' => 7, 'social' => 'Vine' ), array( 'seconds' => 10, 'social' => 'Snapchat' ) );
foreach ($social_media as $value) {
echo "{$value['social']} allows for videos to be {$value['seconds']} seconds long.</br>\n";
}
Upvotes: 2
Views: 151
Reputation: 4499
Bash is a command processor. The programming language is basically meant for executing commands and return the output as text. This output can then be passed as input to other commands.
It does not support complex data structures. It is very limited in this sense. It was never intended to run complex logic, and was designed for simple automation.
Upvotes: 3