Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7091919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:14:52+00:00 2026-05-28T08:14:52+00:00

So i’ve been working on my website in which i’d like to add a

  • 0

So i’ve been working on my website in which i’d like to add a random quote each time the page is loaded from bash.org, i Kinda got it working but i was thinking about using “preg_replace” instead of “array_splice” to get rid of the header and footer of the page. With the code im currently using it get rid of just the header and i cant figure out how to get rid of the footer. Please Help!

Code i currently have

<html>
<head>
    <title>Chris's Website</title>
    <link href="lesson_3_css.css" type"text/css" rel="stylesheet"/>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css"> body, a, a:hover {cursor: url(http://q3ait.org/~bogauschc/WorkInProgress/test/proxy/cur116.cur), progress; scrollbar-3dlight-color:#FFFFFF; scrollbar-arrow-color:#FFFFFF; scrollbar-base-color:#FF9900; scrollbar-darkshadow-color:#333333; scrollbar-face-color:#FF9900; scrollbar-highlight-color:#FFFFFF; scrollbar-shadow-color:#000000;}
body {
    background-image: url(Speaker%20Fire.png);
}
.title div {
    color: #F00;
}
</style>

<script language="JavaScript">
function clock(){
var time = new Date()
var hour = time.getHours()
var minute = time.getMinutes()
var second = time.getSeconds()
var ampm = " PM "
if (hour < 12){
ampm = " AM "
}
if (hour > 12){
hour -= 12
}
if (hour < 10){
hour = " " + hour
}
if (minute < 10){
min = "0" + minute
}
if (second < 10){
second = "0" + second
}
document.clockForm.clockBtn.value = hour + ":" + minute + ":" + second + ampm
setTimeout("clock()", 1000)
}
window.onload=clock;
</script>

</head>
<body>
    <div class="title">
      <div align="center">
        <p>&nbsp;</p>

            <td align="left"><form name="clockForm">
          <input type="button" name="clockBtn" value=" " />
        </form>
        <a><img src="http://www.reliablecounter.com/count.php?page=bogauschc.no-ip.org&digit=style/plain/4/&reloads=0" border="2"></a>
        </br>
      </div>
    </div>
<div class="nav">
  <p><a href="http://q3ait.org/~bogauschc/html">HTML files</a></p>
  <p><a href="http://turntable.fm/mayor_bees_room">My Turntable</a></p>
  <p><a href="http://q3ait.org">Q3AIT</a></p>
  <p><a href="http://www.chathamcentralschools.com/hs/">Chatham High</a></p>
  <p><a href="http://q3ait.org/~bogauschc/WorkInProgress">Work In Progress</a></p>
  <p><a href="games.html">Games</a></p>
  <p><a href="webcams.html">Webcams</a></p>

</div>
    <div class="main" align="center">
</br>
    <p>Im Chris and I Can Do Things!</p>
    <p>&nbsp;</p>
<?php
if(!$_GET['n']) {
$num = rand(1,400);
$open = fopen("http://bash.org/?".$num, "r");
$line = file("http://bash.org/?".$num);
array_splice($line, 0, 83);
array_splice($line, 89, 200);
foreach ($line as $line_num => $line) {
echo $line;
}
}
?>
<p>&nbsp;</p>
<iframe src="//www.facebook.com/plugins/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2Fpages%2FChriss-Website%2F218161641601802&amp;width=292&amp;height=62&amp;colorscheme=light&amp;show_faces=false&amp;border_color&amp;stream=false&amp;header=true" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:292px; height:62px;allowTransparency="true"></iframe>
        <p>&nbsp;</p>
        <script language="JavaScript">
            VIH_BackColor = "palegreen";
            VIH_ForeColor = "navy";
            VIH_FontPix = "16";
            VIH_DisplayFormat = "You are visiting from:<br>IP Address: %%IP%%<br>Host: %%HOST%%";
            VIH_DisplayOnPage = "yes";
    </script>
<script language="JavaScript" src="http://www.hashemian.com/js/visitorIP.js.php"></script>

    <p><a href="IndexOf.html">Index Of Files For This Page</a></p>
</div>
</body>
</html>

here is an example of a bash quote http://bash.org/?47
My website is http://q3ait.org/~bogauschc/

Thats the entire index.php, if you can help get rid of the header and footer it would be much appreciated!

—
Chris

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:14:53+00:00Added an answer on May 28, 2026 at 8:14 am

    First things first – this is a bad way to do this. On the fly is exceptionally bad as ceejay pointed out in his comment. However –

    $data = file_get_contents('http://whatever-bash-url-is.php');
    preg_match_all ("/<p class=\"qt\">([^`]*?)<\/p>/", $data, $matches);
    print_r($matches);
    

    That should give you just what’s in the qt class, which appears to be what you want.

    The RIGHT way to do this – besides asking them for permission to use their content since they don’t appear to offer an API or rss feed – would be to run this on the back end and store every unique quote you get into your own database and serve from that on page load instead of remote URL. You could do this on a cron that runs at a reasonable interval or just write a script and run it yourself.

    Once again – bad idea since you don’t own the content. That’s essentially theft.

    ** this is also considering you said you are ok with changing your code if they change their dom. parser would be better **

    preg_match_all() http://php.net/manual/en/function.preg-match-all.php
    args: pattern, subject, matches

    pattern is the regex you intend to use to cross reference the next arg:
    subject is the contents returned from file_get_contents in this case. It can also just be any string.
    matches is the variable you assign the results to. It can be whatever you want, so

    preg_match_all("\d+", 'long string containing 2 expected digits to match this 1 pattern', $results);
    

    should result in an array like this:

    $results = [
        [0] => 2,
        [1] => 1
    ];
    

    since the numbers 2 and 1 in the string are the only thing that matched the \d+ (digits only) regex pattern I provided.

    Regex can appear horrifying but don’t get discouraged. Basic google searches usually help you find the pattern you need. Or you can ask here.

    By the way, you can also just use preg_match() since you are looking for only one result. I just didn’t know if they came on a page with many results so I went with preg_match_all().

    to avoid empty results, you can just throw a conditional in there:

    foreach($matches AS $m)
    {
        if($m)
        {
            //process only if there is something here
        }
    }
    

    Please note this example above is for preg_match. Preg_match_all will return a multidimensional array, I believe. user basic debugging tools like print_r to widdle this down to what you need.
    Also, I am using this example under the assumption that you are running this on a back end script not initiated by the user. If you want an on the fly option, you should look into ajaxing this request, then making a recursive function that would re-call the bash site if there were no results.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I have a text area in my form which accepts all possible characters from
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.