Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

strrpos() - php

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
SameerMirza
Asked:
SameerMirza
  • 3
  • 2
  • 2
2 Solutions
 
xpert13Commented:
It should work
1123.png
0
 
Beverley PortlockCommented:
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
 
SameerMirzaAuthor Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
xpert13Commented:
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
 
Beverley PortlockCommented:
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
 
SameerMirzaAuthor Commented:
ya logic of this question is that there a was hidden answer in the question :)
0
 
SameerMirzaAuthor Commented:
:) thanks guys
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now