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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.