Jump to content

litebearer

Members
  • Posts

    2,356
  • Joined

  • Last visited

Posts posted by litebearer

  1. My typo...

     

    this:

        if(strlen($temp_array1[0])>10){ $value = substr($dtemp_array1[0], -10) . $needle; }else{ $value = $temp_array1[0] . $needle; }
    
        if(strlen($temp_array1[1])>10){ $tail = substr($dtemp_array1[1], 0, 10); }else{ $tail = $temp_array1[1];}
    

     

    should be:

        if(strlen($temp_array1[0])>10){ $value = substr($temp_array1[0], -10) . $needle; }else{ $value = $temp_array1[0] . $needle; }
    
        if(strlen($temp_array1[1])>10){ $tail = substr($temp_array1[1], 0, 10); }else{ $tail = $temp_array1[1];}
    

     

    $tail will contain any text that follows your search up to 10 characters

     

  2. 1. presumes lines in file.txt terminate with \n
    2. presumes $needle only appears once in a line

    <?php
    $needle = 'https:\/\/superman.com\/';
    $lines = file('file.txt');
    echo"<html><head><title>SEARCH RESULTS FOR: $needle</title></head><body>";
    
    foreach($lines as $line){
      if(stristr($line,$needle)){
        $temp_array1 = explode($needle, $line);
        if(strlen($temp_array1[0])>10){ $value = substr($dtemp_array1[0], -10) . $needle; }else{ $value = $temp_array1[0] . $needle; }
        if(strlen($temp_array1[1])>10){ $tail = substr($dtemp_array1[1], 0, 10); }else{ $tail = $temp_array1[1];}
        echo "<font face='Arial'>" . $value . $tail . "</font><hr>";
    }
    
    ?>
    

     

  3. ginerjm - The points are redemeenable at all S & H Green Stamp stores

     

    OP - people usually are very hesitant to download files from strangers. it is more appropriate to use the proper code tags and display your pertinent files. ALSO make sure you have NOT listed your username/password in the posted files

  4. Perhaps...

    if(isset($_POST)){
        $needle = $_POST['customerId'];
        $new_line = $needle . "," . $_POST['name'] . "," . $_POST['email'];
        $lines = file("customers.csv");
        $c = count($lines);
        $i = 0;
        while($i<$c) {
         $t_array = explode(",", $lines[$i]);
         if($t_array[0] == $needle) { $lines[$i] = $new_line; }
         $new_data = $new_data . $lines[$i] . "\n";
         $i ++;
        }
    
        $file_handle = fopen("customers.csv", 'w');
        fwrite($file_handle, $new_data);
        fclose($file_handle);
    }
    

     

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