striping url to be used as a $variable

They have: 18 posts

Joined: Feb 2005

Any ideas cause Im lost on this one:

url format:
domain.com/abc.1352.html

Im striping the parts like ".html", "abc"
which only leaves the number "1352".

The "1352" is my search criteria:

<?php

$agent
= $_SERVER["REQUEST_URI"];
$agent = str_replace (".html", "", $agent);
$agent = str_replace ("abc", "", $agent);

$lines = file('/home/cgi-bin/cs/data/car.data');
foreach (
$lines as $line) {
$parts = explode('|', $line);
if (
$parts[0] == $_GET[' 1352 ']) {
echo
"$parts[50] ";
}}
?>

this was accomplished by having a url
domain.com/abc.1352.html?&db_id=1352
if ($parts[0] == $_GET[' db_id ']) {

but I would like to trim it down a notch.

CptAwesome's picture

He has: 370 posts

Joined: Dec 2004

$agent = $_SERVER['REQUEST_URI'];
$agent = parse_url($var);
$agent[host] = explode('.',$agent[host]);
$searc_crit = $agent[host][1];

I don't know what else exactly you are trying to accomplish, the code is kind of confusing. I think you need to post a larger snippet, or a clearer indication of what you are trying to accomplish.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.