Jump to content

Recommended Posts

So basically I have a HUGE text file;

download here

or

the code is like this;

FirstName: Wayne, LastName: Brown, CommonName:None, Height: 185, DateOfBirth: Year: 1977, Month: 1, Day: 14, PreferredFoot: Right, ClubId: 1951, LeagueId: 61, NationId: 14, Rating: 54, Attribute1: 56, Attribute2: 53, Attribute3: 47, Attribute4: 61, Attribute5: 36, Attribute6: 49, Rare: 0, ItemType: PlayerGk

but this is repeated like 11,480 times(to be exact) but with different information e.g names ect.

I have the search working ATM like this;

<?php
$search = 'Wayne';
$lines = file('cleanedfutplayers.txt');
$found = false;
foreach($lines as $line)
{
if(strpos($line, $search) !== false)
{
$found = true;
echo $line;
}
}
if(!$found)
{
echo "<i>No match found";
}
?>

And atm I get a return of this;

48f141b3996a7c47aa880b3ce83911b1.png

 

BUT i want to filter it out. I want it to just take the values such as getting the value of first name would just get Wayne and the same for the rest of the fields.

 

and i also need some

<br>

's in there and some spacing. So how would I go about filtering this? Also how would I add a search box and a button that would give and set the value of the;

$search = '';

so for example i THINK the code will be something like this;

echo "First Name: ", ['FirstName'];

but it isnt because ive tested and it doesnt work?

 

so PLEASE help me!

SQL stands for - Structured Query Language. One of the reasons it has been suggested that you use a database for this is because writing a database SQL query statement to do what you want, search (filter) for specific information becomes trivial -

 

$query = "SELECT a, list, of, columns FROM your_table WHERE FirstName = '$search'";

 

Let a database engine do the work for you, rather than you re-inventing the wheel writing your own code to search in your text data. Also, the compiled code of a database engine will be at least 10x faster at finding the data than your parsed, tokenized, interpreted, relatively slow php code will be at finding the data.

SQL stands for - Structured Query Language. One of the reasons it has been suggested that you use a database for this is because writing a database SQL query statement to do what you want, search (filter) for specific information becomes trivial -

 

$query = "SELECT a, list, of, columns FROM your_table WHERE FirstName = '$search'";

 

Let a database engine do the work for you, rather than you re-inventing the wheel writing your own code to search in your text data. Also, the compiled code of a database engine will be at least 10x faster at finding the data than your parsed, tokenized, interpreted, relatively slow php code will be at finding the data.

But how do I put all this data into a database?

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.