Php Inbox window for address!

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
Jackphp
New php-forum User
New php-forum User
Posts: 3
Joined: Fri Dec 01, 2017 10:25 am

Fri Dec 01, 2017 10:31 am

I'm a beginner in php and tried to write a code to find differnt types of numbers which worked perfectly with regex.

Here's my code:
<?php
$contents = file_get_contents('test.txt');
$pattern = '/\b\d{3}([.\s]?)\d{3}\1\d{2}(?:\1\d{1,2})?\b/';
preg_match_all($pattern, $contents, $results);
?>
<style>
ul {
margin: 0;
padding: 0;
list-style: none inside;
}
ul li {
margin: 0;
padding: 5px;
color:#FF1493;
}
</style>
<ul class="">
<?php foreach ($results[0] as $result): ?>
<li><?= $result ?></li>
<?php endforeach; ?>
</ul>
But I have many .txt files in a folder. It makes a lot of work with that code to get all machtes. So i would like to have a code with a Inbox window(?) where i put in the adress of the folder. So i don't want to write the address in the code! It should come at the beginning when i start the code.

Otherwise is it also possible to put the adress in the code. But the folder will change all the time. so i would prefare option 1.

I hope you can help.
And sorry for my English.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 695
Joined: Mon Feb 22, 2016 5:52 pm

Fri Dec 01, 2017 12:06 pm

I not really sure what you are asking, however:

if you want to get all *.txt files, you can use glob

if you want to enter the name of the file, you can use an input box in a form

or you can create an array of file names

thinsoldier
New php-forum User
New php-forum User
Posts: 24
Joined: Sat Dec 02, 2017 3:12 pm

Sat Dec 02, 2017 6:15 pm

I think they want a form where they can paste in a path to a file on the server (hopefully not a url).

Jackphp
New php-forum User
New php-forum User
Posts: 3
Joined: Fri Dec 01, 2017 10:25 am

Sun Dec 03, 2017 5:05 am

I want a code with a input box. And the code should proove all txt.files in this folder.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 695
Joined: Mon Feb 22, 2016 5:52 pm

Sun Dec 03, 2017 7:50 am

How did you get on with the links I provided?

Jackphp
New php-forum User
New php-forum User
Posts: 3
Joined: Fri Dec 01, 2017 10:25 am

Sun Dec 03, 2017 12:01 pm

i don't understand it.
How should i start. And how can I add it to my existing code.
I haven't done a inpu box before.

Can I start like that?
<input id="file" type="file">

But i want all txt files.

User avatar
hyper
php-forum Fan User
php-forum Fan User
Posts: 695
Joined: Mon Feb 22, 2016 5:52 pm

Sun Dec 03, 2017 12:57 pm

I think that you are trying to do more than you are capable of at this point, on the one hand you want to traverse directories, and the other you want to use html input boxes.

Unless you are able to explain exactly what or how you want to do it (whatever 'it' is) I can't offer any help except to suggest that you slow it down and start to learn from the beginning. How would you rate your experience and ability using html, css and php?

Post Reply