Jump to content


Photo

Substr questions


  • Please log in to reply
1 reply to this topic

#1 DarkHavn

DarkHavn
  • Members
  • PipPipPip
  • Advanced Member
  • 69 posts

Posted 24 August 2006 - 09:35 PM

Hey there, currently have a post that's gone quite hrmm how would you put it, out there. lol

The data it returns is

Arrayrandom (and the part i want is random), now substr is abit confusing so far, so how many numbers does it take to get to the letter r, and to delete everything preceeding (before) it?

So the only resullt im left with is ''random'', just want to delete ''array'' from the value :(

#2 SharkBait

SharkBait
  • Members
  • PipPipPip
  • Advanced Member
  • 845 posts
  • LocationMetro Vancouver, BC

Posted 24 August 2006 - 09:43 PM

Think you need to look at strpos();

That will tell you the position of the string then you could substr();

<?php
$loc = strpos("y", "arrayrandom");
$word = substr("arrayrandom", $loc, str_length("arrayrandom"));
?>

I think what that should do is set $loc to 5 then substr arrayrandom starting at position 5 (the "y") and go until end of the length of the rest of the string.

If I am wrong, at least the general idea is there ;)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users