TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-23-2008, 04:00 PM   #1 (permalink)
The Wanderer
 
Join Date: Dec 2007
Location: The Netherlands
Posts: 13
Thanks: 3
Jelmer is on a distinguished road
Confused Strange string comparison problem

I'm making some changes to my site, which is based on vbulletin and some things I made had to be fixed after upgrading vbulletin. I use categories to display some content using an url like this:

So to get the content I need to get the ID associated with that category, it seems simple but when I check if the category exists I run into a problem. I do this by checking if the entered category name is the same as one of the categories from the existing array of categories.

Both strings seem to be the same but the length is different.. Here's some var_dump() from the code:

I've tried various things to "fix" the length of the string using trim() and strlen() but that didn't work.. When I use strlen() to shorten the longer string, nothing remains of it.. here's the code and var_dump:
PHP Code:
$forum_categories fetch_prefix_html 17 );
    
$category_array explode "\n"$forum_categories );
    
$category_array array_filter $category_array );
    
//clean up category array
    
function trim_value(&$value
    {
        
$value trim $value );
    }
    
array_walk $category_array'trim_value' );
    
    
var_dump($category);
    
var_dump($category_array[4]);
    
var_dump strlen($category) );
    
var_dump strlen($category_array[4]) );
    
var_dump($category == $category_array[4]);
    
$category_array_fix substr($category_array[4], 0strlen($category));
    
$category_array_trim trim($category_array[4]);
    
var_dump($category_array_trim);
    
var_dump($category_array_fix); 
Code:
string(11) "compositing" string(52) "compositing" int(11) int(52) bool(false) string(52) "compositing" string(11) "
I hope you can help me out, I'm getting kind of frustrated, it seems a very simple and silly problem but I don't understand what's wrong..
Jelmer is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 04:44 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design