This is an XML question.
Modify the following PHP script to find strings anywhere in the words:
<?php
$q = strtolower($_GET[“q”]);
if (!$q) $q = “ama”; # silly default for testing more easily
$items = file(“entries.txt”, FILE_IGNORE_NEW_LINES);
if (!$items) return; # file not found
if (!$items[0]) return; # file was empty
$maxitems = 30; # too many completions...
$n_found = 0; # number found so far
# look for titles starting with $q
foreach ($items as $key => $value) {
$where = strpos(strtolower($value), $q);
if ($where !== false && $where == 0) {
echo “$value\n”;
if (++$n_found > $maxitems) {
return;
}
}
}
?>
Solution:
-----------------------------------------------------------------------------------
<?php /* Start tag */
$q = strtolower($_GET[“q”]); /* Converting string to lower case .. */
if (!$q)
$q = “ama”; # silly default for testing more easily /* Assigning data.. */
$items = file(“entries.txt”, FILE_IGNORE_NEW_LINES); /* Opening file.. */
if (!$items) /* Condition checking for successfull opening of file.. */
return; # file not found
if (!$items[0]) /* Condition checking.. */
return; # file was empty
$maxitems = 30; # too many completions...
$n_found = 0; # number found so far
# look for titles starting with $q
foreach ($items as $key => $value) {
$where = strpos(strtolower($value), $q);
if(where.exists($q)) /* To find strings anywhere in the words.. */
echo “$value\n”;
else if (++$n_found > $maxitems) {
return;
}
}
}
?>
This is an XML question. Modify the following PHP script to find strings anywhere in the...
PHP - Use of classes This is a further development of the previous task, the participant registration. You must use the following Participant class. <?php class Deltaker { private $etterNavn; private $forNavn; private $fAar; function __construct(string $fornavn, string $etternavn, string $aar) { $this->forNavn = $fornavn; $this->etterNavn = $etternavn; $this->fAar = $aar; } function hentEtterNavn() : string { return $this->etterNavn; } function hentForNavn() : string { return $this->forNavn; } function hentFAar() : string{ return $this->fAar; } //Setters function settForNavn(string $fornavn) {...
IN php .... I need Help I Need to Modify this application so it uses a persistent session to save the last values entered by the user for 5 minutes. At the top of the file (before the DOCTYPE html line) you will need to add a section of code which checks to see if a session id exists. If it does not, the code you add (which will be similar to the example on page 359) will need to...
%%%%Python Question%%% Work from the template acrostic.py, which you can find on the ELMS page for this assignment. • In the Generator class, write an __init__() method with two parameters: self and the path to a text file containing one word per line. This method should read the words from the file, strip off leading and trailing whitespace, and store them in a dictionary where each key is a lower-case letter and each corresponding value is a list of words...
could you please help me with this problem, also I
need a little text so I can understand how you solved the
problem?
import java.io.File; import java.util.Scanner; /** *
This program lists the files in a directory specified by * the
user. The user is asked to type in a directory name. * If the name
entered by the user is not a directory, a * message is printed and
the program ends. */ public class DirectoryList { public static...
Reverse Polish (HP) Style Calculator - Part 3 The purpose of this assignment is to build the business calculator using supporting files built in Topics 4 and 5. Create a Java application file named RPN.java containing a main method by using the ForthStack.java and associated files from Topic 5. The application should have one text box for numeric data entry, one text box for numeric display, one text box for error display, and buttons labeled "+", "-", "*", "/", "dup",...
I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...
python 2..fundamentals of python 1.Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key. 2.Convert Newton’s method for approximating square roots in Project 1 to a recursive function named newton. (Hint: The estimate of...
I would like some assistance correcting an issue I am having with this assignment. Once a finite state automaton (FSA) is designed, its transition diagram can be translated in a straightforward manner into program code. However, this translation process is considerably tedious if the FSA is large and troublesome if the design is modified. The reason is that the transition information and mechanism are combined in the translation. To do it differently, we can design a general data structure such...
The lab for this week addresses taking a logical database design (data model) and transforming it into a physical model (tables, constraints, and relationships). As part of the lab, you will need to download the zip file titled CIS336Lab3Files from Doc Sharing. This zip file contains the ERD, Data Dictionary, and test data for the tables you create as you complete this exercise. Your job will be to use the ERD Diagram found below as a guide to define the...
After pillaging for a few weeks with our new cargo bay upgrade, we decide to branch out into a new sector of space to explore and hopefully find new targets. We travel to the next star system over, another low-security sector. After exploring the new star system for a few hours, we are hailed by a strange vessel. He sends us a message stating that he is a traveling merchant looking to purchase goods, and asks us if we would...