Jump to content

[SOLVED] substr() help


mike1313

Recommended Posts

I've read the documentation on php.net, but still dont full understand.

 

$string = '123456';

$return = substr("$string", 1);

echo "$return";

 

I know that $return will echo 23456.

 

But How can I for instance, using substr be able to echo 345, 456, 56?

 

Please any help is appreciated. Thanks.

Link to comment
https://forums.phpfreaks.com/topic/43841-solved-substr-help/
Share on other sites

This is jumbled but this is the code.

 

if($xy9 > "0" && $xy9 < "10") {
  $do_pm3 = substr("$do_pm2", 1);
  }
  elseif($xy9 > "10" && $xy9 < "100") {
  $do_pm3 = substr($do_pm2, 0, 2);
  }
  elseif($xy9 > "100" && $xy9 < "1000") {
  $do_pm3 = substr("$do_pm2", 0, 3);
  }
  elseif($xy9 > "1000" && $xy9 < "10000") {
  $do_pm3 = substr("$do_pm2", 0, 4);
  }

 

The only string returning anything is the first.

Link to comment
https://forums.phpfreaks.com/topic/43841-solved-substr-help/#findComment-212834
Share on other sites

$xy9 returns a number if that number is a certain number I need it to filter out the beginning of a string.

 

I tried using strlen instead of $xy9=100

 

I just need it to search for a number if its that number remove it from the string. or if strlen=2, 3, 4 I need to remove the 2nd, 3rd, 4th, characters of the string.

 

say strlen=2 I want substr to remove the 2 characters, 3, 4 and so on.

Link to comment
https://forums.phpfreaks.com/topic/43841-solved-substr-help/#findComment-212837
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.