Jump to content

pag08007

New Members
  • Posts

    4
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

pag08007's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. well the reason I am creating this page is so that I have a more efficient way of obtaining and storing the I.P. addresses of all the workers at my job. People get lazy, especially when doing things on the computer, and they sometimes forget to capitalize their names. But I still want it to be listed in alphabetical order by last name regardless of case so that the file is more organized. Also thank you, natcasesort() worked perfectly!
  2. Thank You so much it works perfectly. I have one more quick question and that is: how do you sort an array so that case doesn't matter. I was trying to look for a sort function that wasn't case sensitive but couldn't find one. Is there a method like that or would I have to create my own function that does this?
  3. sorry about the confusion Wolfie. The variable "$textFromFile" was from a commented out and when I tried to clean up my code before posting I overlooked this. So therefore there is no point of "$newText". With that said it still worked fine because it treated "$textFromFile" as an empty string apparently. So how you implemented it into your code was fine. But I tried using your code and for some reason nothing is written in my text file. Your logic makes sense to me but it doesn't print. I also tried seeing if it printed on the web page its self but it also did not print there. Any more suggestions? Thanks
  4. I am working on php script that takes an input (using html) stores those values in a separate text file. I managed to get that to work. But the thing is I wanted to be able to sort those values alphabetically. Since their are an unspecified amount of inputs I tried using an explode on my output in order to store those values as an array so that I can sort them. Problem is explode makes each input its own separate array instead of one whole array. I figure some type of loop is needed to fix that but I can't figure out how to go about creating it [i'm pretty new to php]. Any advice? Heres my code for my PHP script: $filename = "ip_collection.txt"; $fileHandle = fopen('ip_collection.txt', 'a+') OR die("can't open file\n"); $ip = $_SERVER['REMOTE_ADDR']; $name = stripslashes($_POST['lastName'] . ", " . $_POST['firstName']); $textFromForm = $name. " | " . $ip; $newtext = $textFromFile . $textFromForm; $output = explode("\n",$newtext); sort($output); foreach($output as $key => $value) { fwrite($fileHandle, $value."\n"); } fclose($fileHandle);
×
×
  • 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.