Generating fixed-width field data records without : Multidimensional Array « Data Structure « PHP






Generating fixed-width field data records without

 
<?php

$books = array( array('A','S', 1927),
                array('T','L',1971),
                array('T','W',1979) );

foreach ($books as $book) {
    $title  = str_pad(substr($book[0], 0, 25), 25, '.');
    $author = str_pad(substr($book[1], 0, 15), 15, '.');
    $year   = str_pad(substr($book[2], 0, 4), 4, '.');
    print "$title$author$year\n";
}

?>
  
  








Related examples in the same category

1.Reference element in multidimensional Arrays
2.Defining a Multidimensional Array
3.Looping Through a Multidimensional Array
4.Displaying a Multidimensional Array using For each
5.Accessing multidimensional array elements
6.Creating Multidimensional Arrays
7.Creating a Multidimensional Array
8.Sorting Multidimensional Arrays
9.Multidimensional array element value interpolation
10.Displaying Multidimensional Arrays
11.Displaying a multidimensional array
12.Find the Maximum Value in a Multidimensional Array
13.Manipulating multidimensional arrays