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 163125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:30:45+00:00 2026-05-11T11:30:45+00:00

Okay so i set up this thing so that I can print out page

  • 0

Okay so i set up this thing so that I can print out page that people came from, and then put dummy tags on certain pages. Some pages have commented out ‘linkto’ tags with text in between them.

My problem is that some of my pages don’t have ‘linkto’ text. When I link to this page from there I want it to grab everything between ‘title’ and ‘/title’. How can I change the eregi so that if it turns up empty, it should then grab the title?

Here is what I have so far, I know I just need some kind of if/then but I’m a rank beginner. Thank you in advance for any help:

<?php $filesource = $_SERVER['HTTP_REFERER']; $a = fopen($filesource,'r'); //fopen('html_file.html','r'); $string = fread($a,1024); ?> <?php if (eregi('<linkto>(.*)</linkto>', $string, $out)) {      $outdata = $out[1]; } //echo $outdata; $outdatapart = explode( ' ' , $outdata); echo $part[0]; ?>  
  • 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. 2026-05-11T11:30:45+00:00Added an answer on May 11, 2026 at 11:30 am

    Here you go: if eregi() fails to match, the $outdata assignment will never happen as the if block will not be executed. If it matches, but there’s nothing between the tags, $outdata will be assigned an empty string. In both cases, !$outdata will be true, so we can fallback to a second match on the title tag instead.

    if(eregi('<linkto>(.*?)</linkto>', $string, $link_match)) {     $outdata = $link_match[1]; } if(!$outdata && eregi('<title>(.*?)</title>', $string, $title_match)) {     $outdata = $title_match[1]; } 

    I also changed the (.*) in the match to (.*?). This means, don’t be greedy. In the (.*) form, if you had $string set to

    <title>Page Title</title>  ...    ... <iframe><title>A second title tag!</title></iframe> 

    The regex would match

    Page Title</title> ... ... <iframe><title>A second title tag! 

    Because it tries to match as much as possible, as long as the text is between any and any other !. In the (.*?) form, the match does what you’d expect – it matches

    Page Title 

    And stops as soon as it is able.

    …

    As an aside, this thing is an interesting scheme, but why do you need it? Pages can link to other pages and pass parameters via the query string:

    <a href='somescript.php?prevpage=Foo'>...</a> 

    Then somescript.php can access the prevpage parameter via the $_GET[‘prevpage’] superglobal variable.

    Would that solve your problem?

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

Sidebar

Related Questions

Okay so I can't figure this out. Like a file that I using grep
Okay, so I have this form that is set to preload a DB record
Okay, next PHPExcel question. I have an HTML form that users fill out and
Okay this question is very simple: I have a facebook page, and a website.
Okay, this may be trivial, but I'm hoping somebody can give me a straightforward
Okay, this is something that should be a simple matrix question, but my understanding
Okay, so, I'll preface this by stating I'm using Titanium, so that'll, I assume,
Okay, I'm going out on a limb here, because I'm not sure this functionality
Okay, I've been working through a set of string replacments for bbcode style tags
okay, so I'm trying to set up a webpage with a div wrapping two

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.