You are here: Re: Problem with multidimensional array « PHP Programming Language « IT news, forums, messages
Re: Problem with multidimensional array

Posted by Oli Filth on 06/17/05 16:46

Georg Ringer said the following on 17/06/2005 14:34:
> Hi,
>
> I've got a multidimensional array which looks like this:
> $data[] = array('nname' => 'Auerbach', 'vname' => 'Berthold', 'uid' => 20);
> $data[] = array('nname' => 'Bloch', 'vname' => 'Ernst', 'uid' => 24);
> $data[] = array('nname' => 'Shaw', 'vname' => 'George Bernard', 'uid' =>19);
> $data[] = array('nname' => 'Wilde', 'vname' => 'Oscar', 'uid' => 12);
> $data[] = array('nname' => 'Wilder', 'vname' => 'Thornton', 'uid' => 38);
> .......
>
> And I've got the following code, which splitts the last names (nname) =>
> $az = array ('ABC','DEF','GHI','JKL','MNO','PQR','STU','VWX','YZ');
> $x = 0;
> foreach($data as $name) {
> if(substr($name[nname], 0,1) == substr($az[$x], 0,1) ||
> substr($name[nname], 0,1) == substr($az[$x], 1,2) || substr($name[nname],
> 0,1) == substr($az[$x], 2,3)) {
> if($az[$x] != $alt) {
> echo "<br /><big><b>".$az[$x]."</b></big><br />";
> $alt = $az[$x];
> $x = $x + 1;
>
> }
> }
> echo $name[nname].', '.$name[vname]."<br />";
> }
>
> You can see the problem here:
> http://inside.eventshooters.com/typo3conf/ext/rg_zitate/pi1/test.php
>
> Kant, Immanuel => GHI
> Waggerl, Karl Heinrich => STU
> Wilde, Oscar => STU
> Wilder, Thornton => STU
>
> Where is my problem?
> Please help me!

Check the syntax for substr().
http://www.php.net/substr

--
Oli

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация