Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
inlab-9
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huffleclaw
inlab-9
Commits
f70bd363
Commit
f70bd363
authored
Oct 05, 2017
by
Harsh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new files
parent
86e55aac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
117 additions
and
0 deletions
+117
-0
Q4/index.php
Q4/index.php
+72
-0
Q5/indx.html
Q5/indx.html
+15
-0
Q5/q5.php
Q5/q5.php
+30
-0
No files found.
Q4/index.php
0 → 100644
View file @
f70bd363
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<title></title>
<link
rel=
"stylesheet"
href=
""
>
</head>
<style
type=
"text/css"
media=
"screen"
>
table
,
th
,
td
{
border
:
1px
solid
black
;
border-collapse
:
collapse
;
}
</style>
<body>
<form
onsubmit=
"return Validate();"
method=
"post"
enctype=
"multipart/form-data"
>
<script
type=
"text/javascript"
charset=
"utf-8"
async
defer
>
function
Validate
()
{
var
filename
=
document
.
getElementById
(
"
up
"
);
var
checker
=
new
RegExp
(
"
([a-zA-Z0-9
\
s_
\\
.
\
-:])+(.txt)$
"
);
if
(
!
checker
.
test
(
filename
.
value
))
{
window
.
alert
(
"
Please upload file with extension '.txt'
"
);
return
false
;
}
else
return
true
;
}
</script>
Upload File:
<input
type=
"file"
name=
"upload"
id=
"up"
/><br><br>
<input
type=
"submit"
name=
"submit"
/>
</form>
<?php
$freq
=
array
();
if
(
isset
(
$_POST
[
"submit"
]))
{
$f
=
$_FILES
[
"upload"
][
"tmp_name"
];
if
(
filesize
(
$f
)
<
100000
)
echo
"File size must be greater than 100kB!"
;
else
{
$myFile
=
fopen
(
$f
,
"r"
)
or
die
(
"Unable to open file"
);
while
(
!
feof
(
$myFile
))
{
$line
=
fgets
(
$myFile
);
$words
=
str_word_count
(
$line
,
1
);
foreach
(
$words
as
$i
=>
$w
)
{
$ww
=
strtolower
(
$w
);
if
(
array_key_exists
(
$ww
,
$freq
))
$freq
[
$ww
]
++
;
else
$freq
[
$ww
]
=
1
;
}
}
fclose
(
$myFile
);
ksort
(
$freq
);
}
}
?>
<?php
if
(
count
(
$freq
)
>
0
)
:
?>
<br><br>
<table>
<tr>
<th>
Words
</th>
<th>
Frequency
</th>
</tr>
<?php
foreach
(
$freq
as
$key
=>
$value
)
:
?>
<tr>
<td>
<?php
echo
$key
?>
</td>
<td>
<?php
echo
$value
?>
</td>
</tr>
<?php
endforeach
;
?>
</table>
<?php
endif
;
?>
</body>
</html>
\ No newline at end of file
Q5/indx.html
0 → 100644
View file @
f70bd363
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<title></title>
<link
rel=
"stylesheet"
href=
""
>
</head>
<body>
<form
action=
"q5.php"
method=
"post"
>
Enter array:
<input
type=
"text"
name=
"arr"
/>
<input
type=
"submit"
name=
"submit"
/>
</form>
</body>
</html>
\ No newline at end of file
Q5/q5.php
0 → 100644
View file @
f70bd363
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<title>
Q5
</title>
<link
rel=
"stylesheet"
href=
""
>
</head>
<body>
<?php
$nums
=
explode
(
','
,
$_POST
[
"arr"
]);
$i
=
0
;
$len
=
count
(
$nums
);
while
(
$i
<
$len
)
{
if
(
$i
==
0
)
$i
++
;
if
(
$nums
[
$i
]
>=
$nums
[
$i
-
1
])
$i
++
;
else
{
$temp
=
$nums
[
$i
];
$nums
[
$i
]
=
$nums
[
$i
-
1
];
$nums
[
$i
-
1
]
=
$temp
;
$i
--
;
}
}
for
(
$j
=
0
;
$j
<
$len
;
$j
++
)
echo
$nums
[
$j
]
.
" "
;
?>
</body>
</html>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment