i have this code:
<?php var_dump(strpos($url, "cashgold.")+9) ?>
<?php var_dump(strpos($url, '/', 8)) ?>
<?php $resta = strpos($url, '/', 8) - strpos($url, "cashgold.")+9 ?>
<?php var_dump($resta) ?>
this prints:
20
22
20
I expected it prints :
20
22
2
I think you’re having issues with maths – specifically with operator precedence.
When you’re doing
you’re doing (22 – 11) + 9. This is because + and – are the same precedence, so it’s being evaluated left to right.
Try (note the brackets)
to do the calculation you’re after.