Jump to content

PHP strrpos() help.


nano

Recommended Posts

Hey Guys,

 

I have the following string:

 

184 - fashion - 4 x 6 Inches - (£2.00)

 

And I am trying to retrieve the 184, using the strrpos() function, it seems to take everything before the last occurrence of '-'..

 

I thought strrpos() would stop at first occurrence and pass me the 184 :(

 

Anyone have any ideas how I can pull back just the numbers before the first '-'?

 

Sample:

 

$input1 = strrpos($_POST['product'],"-");
$article = substr($_POST['product'],0,$input1);

 

$article outputs: 184 - fashion - 4 x 6 Inches

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/237568-php-strrpos-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.