PHP: Grab (trim) a part of a string?

Discussion in 'Programming/Scripts' started by edge, Jun 12, 2007.

  1. edge

    edge HowtoForge Supporter

    I've got a $titleA that is set to random text "this is need" more random text

    When I do a echo $titelA; in PHP, it does show random text "this is need" more random text

    What I need is ONLY the part between the quotes (so this is need)

    In Coldfusion (my coding language) it's simply done with a "trim" option, but how do I do this in PHP?
  2. Ben

    Ben HowtoForge Supporter

    you could do this with
    the other thing is to do it with preg_match, like the following but this is untestet...
  3. edge

    edge HowtoForge Supporter

    Thank you Ben,

    list(,$wanted,) = explode('"', $titleA); got me going :)
  4. sjau

    sjau Local Meanie

    $wanted = explode('"', $titleA);
    $wanted = $wanted[1];
    Note: Arrays start with element "0" so it's element "1"...

Share This Page