Jump to content

search the array where the id equals the get


dezkit

Recommended Posts

i have this code

<?php
$rulepages = array();
$rulepages[] = array("name" => "1111213", "page" => "fasdd21.php", "id" => "1");
$rulepages[] = array("name" => "41231245152", "page" => "fasd.php", "id" => "2");

?>
<table width="100%">
<tr>
	<td width="15%">
	<?php
		sort($rulepages);
		foreach($rulepages AS $rulepage){
			echo "<a href=\"?id=".$rulepage["id"]."\">".$rulepage["name"]."</a>";
			echo "<br />";
		}
	?>
	</td>
	<td  width="80%">
		<?php
			$id = $_GET["id"];
			// ??
		?>
	</td>
</tr>
</table>

what do i do to search the array where the id equals the get ?

 

thanks

			<?php
			$id = $_GET["id"];
			foreach ($rulepages as $rulepage) {
                                     if ($rulepage['id'] == $id) {
                                           // $rulepage is the one matching $_GET['id']
                                     }
                                }
		?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.