vendredi 8 mai 2015

Work around for multidimensional arrays in bash?

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";
}

Aucun commentaire:

Enregistrer un commentaire