/    Sign up×
Community /Pin to ProfileBookmark

Matching first three of a file

What I have so far, preg_match isn’t working though.
All it’s doing is saying “If the file starts like this, then
the title must be this.”, I thought I could do it with
arrays but couldn’t get that working either….

[code=php]
<?php

echo “<pre>r”;
echo “t<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes”?>r”;
echo “t<rss version=”2.0″ xmlns:media=”http://search.yahoo.com/mrss/”r”;
echo “txmlns:atom=”http://www.w3.org/2005/Atom”>r”;
echo “t<channel>r”;

$t = “ttt”;
$base = “http://omnisistem.com/images/media/tradeshows/”;
$dir = opendir (“../images/media/tradeshows/explode/”);
while (false !== ($file = readdir($dir))) {
if (strpos($file, ‘.gif’,1)||strpos($file, ‘.jpg’,1) ) {
$item = “rtt<item>”;
$item .= “r$t<title>”;

# NAMM Tripcodes
if(preg_match(‘/^n09/’, $file, $card, PREG_OFFSET_CAPTURE, 3)) { $item .= ‘NAMM 2009’; }
if(preg_match(‘/^n08/’, $file, $card, PREG_OFFSET_CAPTURE, 3)) { $item .= ‘NAMM 2008’; }
if(preg_match(‘/^n02/’, $file, $card, PREG_OFFSET_CAPTURE, 3)) { $item .= ‘NAMM 2002’; }

# LDI Tripcodes
if(preg_match(‘/^l08/’, $file, $card, PREG_OFFSET_CAPTURE, 3)) { $item .= ‘LDI 2008’; }
if(preg_match(‘/^l07/’, $file, $card, PREG_OFFSET_CAPTURE, 3)) { $item .= ‘LDI 2007’; }
if(preg_match(‘/^l06/’, $file, $card, PREG_OFFSET_CAPTURE, 3)) { $item .= ‘LDI 2006’; }
if(preg_match(‘/^l05/’, $file, $card, PREG_OFFSET_CAPTURE, 3)) { $item .= ‘LDI 2005’; }
if(preg_match(‘/^l01/’, $file, $card, PREG_OFFSET_CAPTURE, 3)) { $item .= ‘LDI 2001’; }

$item .= “</title>r”;
$item .= “$t<link>explode/$file</link>r”;
$item .= “$t<media:thumbnail url=”$base/thumb/$file”/>r”;
$item .= “$t<media:content url=”$base/explode/$file”/>r”;
$item .= “tt</item>r”;

echo $item;
}
}

echo “rt</channel>rt</rss>”;
echo “r</pre>”;?>
[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @ehime spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...