?
Solved

strrpos() - php

Posted on 2010-01-12
7
Medium Priority
?
280 Views
Last Modified: 2013-12-13
hi,
strrpos() ir not behaving nice with '\'
strpos('abc\ntp' , '\'); wouldn't work
I even tried strpos('abc\ntp' , '\\');#

Can any one please tell me the trick to make it work or mayb an alternative..I am flexible :-)

thanks,
SM.
0
Comment
Question by:SameerMirza
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Accepted Solution

by:
xpert13 earned 1000 total points
ID: 26293555
It should work
1123.png
0
 
LVL 34

Assisted Solution

by:Beverley Portlock
Beverley Portlock earned 1000 total points
ID: 26293563
strpos('abc\ntp' , '\\'); should work OK. Put this at the start of your script

ini_set('display_errors', 1);
error_reporting(E_ALL);

and see what messages pop up.
0
 

Author Comment

by:SameerMirza
ID: 26293613
amazing I had answe in my own question. sometime my code doesn't work coz it just doesn't want to work :)
who wants the points now.:)
0
7 Extremely Useful Linux Commands for Beginners

Just getting started with Linux? Here's a quick start guide that has 7 commands that we believe will come in handy.

 
LVL 2

Expert Comment

by:xpert13
ID: 26293615
Alternative way:
<?php
$a = 'abc\ntp';

function MyStrPos($str){
	$i = 0;
	$result = -1;
	while ($i < strlen($str)) {
		if($str[$i] == '\\'){
			$result = $i;
			break;
		}
		$i++;
	}
	
	return $result;
}

echo MyStrPos($a);
?>

Open in new window

0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 26293747
I suggest an equal split - we both said the same thing at the same time. Failing that get the question deleted for a full refund.
0
 

Author Comment

by:SameerMirza
ID: 26293934
ya logic of this question is that there a was hidden answer in the question :)
0
 

Author Closing Comment

by:SameerMirza
ID: 31676108
:) thanks guys
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question