Jump to content

Substr questions


DarkHavn

Recommended Posts

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 :(
Link to comment
Share on other sites

Think you need to look at strpos();

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

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

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 ;)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.