Having Array Issues

please can any help me with this code:
I have two array having different data and i want to output them in a table row.
first array $age = array(‘date’ => ‘date’ …);
second array $name = {‘ebiwari’,‘douebo’…}

how do i output this for name to always take is column in the table:

This what i did. but the name remain the same…

<?php foreach($age as $age): ?>
<tr>

&lt;?php echo "&lt;td&gt;".$name[0]."&lt;/td&gt;"; ?&gt;

  	
&lt;td&gt;&lt;?php echo  "NID".$age['userId']."2012"; ?&gt;&lt;/td&gt;  		
&lt;td&gt;&lt;?php echo  $age['placeOfBirth']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo  $age['date']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo  $age['sex']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo  $age['state']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo  $age['lga']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo  $age['community']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo  $age['villageHead']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo  $age['occupation']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo  $age['fatherName']; ?&gt;&lt;/td&gt;
&lt;td&gt;&lt;?php echo  $age['age']; ?&gt;&lt;/td&gt;

&lt;?php
	
?&gt;

</tr>

<?php endforeach; ?>

Hi,
You would need to set up a simple counter that increased each time the loop was run.
As a basic example:


$i=0;
$name = array("Spike", "ebiwari", "dave");
foreach($name as $data) {
    echo $data[$i]; // print out an example data value
    $i++; //increment the value of $i;
}

You might want to re-check that code @spikeZ; , as it stands it will output “Sbv” :wink:

Spike ebiwari dave


$names = array("Spike", "ebiwari", "dave");
foreach($names as $name) {
    echo $name; // print out an example data value
}  

@OP you should probably use something like this


<?php foreach($age as $i => $age): ?>
<tr>	

<?php echo "<td>".$name[$i]."</td>"; ?>

(added $i)

Not sure, because I don’t know what $name is, or what it’s relation to $age is.

Thanks alot u are a genius… It does the job

Good spot Remon, I was thinking of a different loop :blush: