bloodgoat Posted April 14, 2009 Share Posted April 14, 2009 Or something along those lines... how would I go about this? Say this is my array: <?php $array = array(); $array[] = array("value 1a", "value 2a", "value 3a"); // [0] $array[] = array("value 1b", "value 2b", "value 3b"); // [1] $array[] = array("value 1c", "value 2c", "value 3c"); // [2] ?> Now let's say I would like to clear $array[1] from the file. How would I go about doing this? foreach() or for() loop? Or what... Link to comment https://forums.phpfreaks.com/topic/153945-using-strstr-to-find-a-line-and-fwrite-to-delete-it/ Share on other sites More sharing options...
bloodgoat Posted April 14, 2009 Author Share Posted April 14, 2009 ~ Just looking around... would preg_replace or something be a better option? Or... I really have no idea how to approach this. I mean, for my real application, I have: USERS.PHP <?php $users = array(); $users[] = array("user 1", "pass 1", "2"); $users[] = array("user 2", "pass 2", "2"); $users[] = array("user 3", "pass 3", "3"); // "username", "password", "permissions" ?> Then I have a MANAGE_USERS.PHP file which I'm trying to work with right now to implement a "delete user" system. Base URL is "?action=manage_users" and for the deleting function, I want it to link like "?action=manage_users&delete=WhateverUserWasSelected". This is all I have so far: <?php include("./users.php"); if(!isset($_GET['delete'])){ $content .= "<table width=\"900\" cellpadding=\"4\" cellspacing=\"0\">\n"; foreach($users as $user_list){ $content .=" <tr> <td width=\"50%\" class=\"apleft\">".$user_list[0]." (".$user_list[2].")</td> <td width=\"50%\" class=\"apright\"><a href=\"?action=manage_users&delete=".$user_list[0]."\">Delete</a></td> </tr>\n"; } $content .= " <tr>\n <td class=\"apfoot\" colspan=\"2\"> </td>\n </tr>\n</table>"; } ?> So pretty much, just the table showing the full userlist, and an option to delete. But I don't know how to approach actually making the delete feature work. Link to comment https://forums.phpfreaks.com/topic/153945-using-strstr-to-find-a-line-and-fwrite-to-delete-it/#findComment-809141 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.