/    Sign up×
Community /Pin to ProfileBookmark

Help with creating tags?

[code=php]//Tags
$tag_name = preg_replace(‘/^,/’,”,$tag);
$tag_name = preg_replace(‘/,$/’,”,$tag_name);
$tag_name = preg_replace(‘/s*/’,”,$tag_name);
$tag_name = $tag_name . ‘,’;
$num_tags = preg_replace(‘/[^,]+/’,”,$tag_name);
$num_tags = strlen($num_tags);
$tag = array();
while( $num_tags > 0 )
{
$tag[] = preg_replace(‘/,.*$/’,”,$tag_name);
$tag_name = preg_replace(‘/^[^,]+/’,”,$tag_name);
$tag_name = substr($tag_name,2,25);
$num_tags = $num_tags – 1;
}[/code]

I don’t know why, but the first letter of each tag always gets cut off. Help?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 26.2010 — While I have no idea what's going on (I don't want to think that hard), I suspect you may be forgetting that with substr(), the first character in the string is at position 0 (zero).
Copy linkTweet thisAlerts:
@importuneJul 26.2010 — NogDog's right- take another look while remembering to start at zero.
×

Success!

Help @narutodude000 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.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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