Edit report at http://bugs.php.net/bug.php?id=52198&edit=1
ID: 52198 Updated by: ras...@php.net Reported by: christian dot gnoth at arcor dot de Summary: strpos not working correctly -Status: Open +Status: Bogus Type: Bug Package: Strings related Operating System: Linux PHP Version: 5.2.13 New Comment: Based purely on your bug description, you are saying this doesn't work? <?php $haystack = 'href="index.php?option=com_content&view=article&id=9257:2009-fha- loan-limits&catid=52:fha&Itemid=97"'; $needle = 'article&id='; echo strpos($haystack,$needle); When I run this I get: 40 which looks correct. Please simplify your reproduce code and I bet you will find that your mistake is elsewhere. Previous Comments: ------------------------------------------------------------------------ [2010-06-28 12:04:39] christian dot gnoth at arcor dot de Description: ------------ Hello, I try to find a string in another string using strpos. If both the string are passed to the strpos function enclosed in ' it is working properly and the position is returned. If I put the string - in which the other string has to be find - in a variable and pass the variable to the strpos function I get FALSE. Maybe a problem of character conversion or php configuration???? the website is: joomla-wp.it-gnoth.de with it-gnoth.de/phpinfo.php your will see the complete configuration. the string which is to be searched: href="index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97" the string which has to be find: article&id= below the php source code - both if version get the same result. It goes always in the else tree. Test script: --------------- function j2wp_change_single_url( $j2wp_post, $lnk_pos ) { global $CON, $wpdb; $j2wp_wp_tb_prefix = get_option('j2wp_wp_tb_prefix'); $j2wp_joomla_tb_prefix = get_option('j2wp_joomla_tb_prefix'); $permalink = false; // $lnk_pos ---> pos at href=" string in post_content // $post_lnk_end ---> pos at last " in link string of post_content // $post_lnk_string ---> contains the whole link string inkl. " at the end $post_lnk_end = strpos( $j2wp_post['post_content'], '"', $lnk_pos + 7); $post_lnk_string = substr( $j2wp_post['post_content'], $lnk_pos, $post_lnk_end - $lnk_pos + 1 ); if ( !(strrpos( $post_lnk_string, '/') === false) ) $pos_lnk_last_slash = strrpos( $post_lnk_string, '/'); // urls with structure: index.php?option=com_content&view=article&id=9257:2009-fha-loan-limits&catid=52:fha&Itemid=97 // if ( !(strpos( $post_lnk_string, 'article&id=') === false) ) if ( $pos_article_id = strpos( $post_lnk_string, 'article&id=') ) { $pos_article_id += 11; $article_id = j2wp_extract_number( substr( $post_lnk_string, $pos_srticle_id ) ); $url_post_id = j2wp_get_post_url_for_id( $article_id ); $permalink = get_permalink( $url_post_id ); } else { ...... ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52198&edit=1