Create multiple (n) arrays
Posted on
16th Feb 2014 07:03 pm by
admin
Hi there,
I have the following need:
I have 2 arrays (coming from a databases)
Array2 is related to Array1 -
Example:
Array1
Dog, abc
Cat, bcd
Horse, cde
Array2,
meat, abc
bones, abc
fish, bcd
grain, cde
grass, cde
So, I need the array2 split up into separate arrays - but I am will never know in advance how many rows in both arrays there will be.
Basically, I need to display the data so:
Dog
<ul>
<li>meat</li>
<li>bones</li>
</ul>
Cat
<ul>
<li>fish</li>
</ul>
Horse
<ul>
<li>grain</li>
<li>grass</li>
</ul>
As said, the second array will change very often - but will always have the key from the first array
Any help very much appreciated. I do have it sort of working - but EVERY entry from array2 appears under every entry from array1 :-
here is the code that I have so far written:
Code: <?php
$fquestions = $record->getRelatedSet('Markt.FFragen');
$questions = $record->getRelatedSet('FFragen.Fragen');
foreach( $fquestions as $fquestion ) {
$ffrage = $fquestion->getField('Markt.FFragen::fFrage');
$ffgroup = $fquestion->getField('Markt.FFragen::ffgroup');
$ffrageID = $fquestion->getField('Markt.FFragen::ID');
echo'<h3><a href="#">'.$ffrage.'</a></h3>
<div>
<ul>';
foreach( $questions as $question ) {
$frage = $question->getField('FFragen.Fragen::Frage');
$frageID = $question->getField('FFragen.Fragen::ID');
echo '<li>'.$frage.'<div id="slider"></div></li>';
}
echo '</ul>
</div>';
}
?>
Many thanks in advance
No comments posted yet
Your Answer:
Login to answer
274
6
Other forums
max function question
Hi All
Ihave a table that holds shipment numbers and dates like this
select * from
php libs/ browsercap.in
ok i have a host that refuses to stay current. they control my php settings and libs. is there a way
Get last modified date of web page
Hai All,
In php how can i get last modified date of a give web page . I have tried to g
Weekly Calendar
Hi, I am looking at creating a weekly calendar. The calendar will read from Monday - Sunday. Does an
Parse XML
Good day,
I use oempro software and try to parse XMLReturn but it's not working for me, simpl
try catch error
I have been trying try catch but, I can't get it to work. The code opens a non existing file called
Sequre login with cookies.
I want to build secure login with cookies. I just want your ideas about this, your suggestions. What
parameter passing issue on function
Well I thought I had created a pretty slick web page, using ?page and $_GET to load pages which wher
Prevention Help
How can I use PHP or any other language (feel free to move this thread) to prevent users doing scree
Staff Induction System - No idea where to go from here!!!
Hi there, I'm pretty new to PHP and Mysql so could really do with being pointed in the right directi