PHP Scripting

BlackVikingPro
8 years ago

0

Hello, World. I have something I’d like to do in PHP using the file_get_contents() method in php7. So, below you’ll see some php code that I need to use with the new function. Thanks for helping in advance…

$a[] = "foo";  

// get the q parameter from URL  
$q = $_GET["user"];  

$hint = "";  

// lookup all hints from array if $q is different from ""   
if ($q !== "") {  
    $q = strtolower($q);  
    $len=strlen($q);  
    foreach($a as $name) {  
        if (stristr($q, substr($name, 0, $len))) {  
            if ($hint === "") {  
                $hint = $name;  
            } else {  
                $hint .= ", $name";  
            }  
        }  
    }  
}  

So, you see that up there you have $a[] = "foo";. This will echo “foo” if the GET parameter is equal to “f” or “fo” or “foo”.
So, instead of $a[] = "foo"; I want to make it read the document “comm_names.txt” line for line, then render that in the php script so it will automatically do the $a[] = with automatically inserting data retrieved from “comm_names.txt”.

If you need a more detailed description, or whatever, please don’t hesitate to ask me :D. Again, thanks in advance!

6replies
6voices
212views
1image
SIGKILL [r4v463]
8 years ago

2

Let say that I didn’t see that you’re spamming lot of threads that are asleep since few weeks/months, here is your answer : http://lmgtfy.com/?q=get%20the%20file%20content%20line%20per%20line%20php#

BlackVikingPro
8 years ago

0

Ok, @r4v463 . Thanks for your suggestion, though I asked for answers in code, not a link.

dloser
8 years ago

0

I think the idea is that you asked such a simple question that just googling should have been enough to answer it. But apparently you didn’t even get that from the link.

cn9 [1337boy]
8 years ago | edited 8 years ago

3

Well if you prefer the answer in code here it is:
http://lmgtfy.com/?q=get%20the%20file%20content%20line%20per%20line%20php#

SIGKILL [r4v463]
8 years ago

0

@BlackVikingPro Sorry if I don’t do your job for you.

Btw, as you told in another thread [quote=BlackVikingPro]Obviously, none of you know anything about SSL or anything[/quote] , so stop asking us help if we don’t know anything.

Kerachi
8 years ago | edited 8 years ago

0

[quote=BlackVikingPro]I want to make it read the document “comm_names.txt” line for line[/quote]
Do you mean this?
```<?php
$file = fopen(“comm_names.txt”,“r”);

while(! feof($file))
{
echo fgets($file). “
”;
}

fclose($file);
?> ```
from http://www.w3schools.com/php/func_filesystem_fgets.asp or i just misunderstand what you asked?

3 replies have been removed
You must be logged in to reply to this discussion. Login
1 of 7

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss