Results 1 to 4 of 4
  1. #1
    Join Date
    June 8th, 2005
    How to append a string into an array in PHP?
    How do I append a string, ex. a delimiter '/' into an array?

    My example:
    $pattern = '/' . $keywords . '/';

    $keywords is an array but the $pattern won't turn into an array.

  2. #2
    Member sendmemybill's Avatar
    Join Date
    August 6th, 2005
    St-Georges, Québec, Canada
    $pattern = array('/','$keywords','/');
    But if $keywords is an array itself, I don't assume it can works. Well I'm not pretty sure to know what you want exactly, maybe more explanations could help me to help you.
    "Effective people are not problem-minded; they're opportunity minded. They feed opportunities and starve problems."

  3. #3
    Just Lurking
    Join Date
    January 18th, 2005
    Try ...
    PHP Code:
    array_walk($keywordscreate_function('&$v,$k''$v = "/" . $v . "/";'));
    $pattern $keywords
    Lead, Follow or Get Out of the Way!

  4. #4
    Fear and Arrogance jrrl's Avatar
    Join Date
    January 18th, 2005
    Well, if you want to do the operation on every item of the array, then do what Buddha said.

    This should take ("a", "b", "c") and give you ("/a/", "/b/", "/c/").

    If you actually mean that you want to put your delimiter at the beginning and end of your array, then try something like this:

    $newarray = array_merge((array) "/", $oldarray, (array) "/");
    This SHOULD take ("a", "b", "c") and give you ("/", "a", "b", "c", "/").

    There's a reason army's wear uniforms even though it makes them easier to spot. Sometimes that's what you want. Uniforms suggest organization, power, and numbers. These, in turn, inspire fear. And, as any good operative knows, there is no more effective weapon than fear.

    Hosting Comparison - HostScope -

  5. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Need Help - How to Creating Tracking URL/Append SubID
    By kylekangaroo2011 in forum Programming / Datafeeds / Tools
    Replies: 1
    Last Post: May 30th, 2012, 04:54 PM
  2. Does datafeed append?
    By Tami in forum Google Affiliate Network - GAN
    Replies: 0
    Last Post: May 20th, 2007, 08:00 AM
  3. Dynamically append parameters to links
    By grafx77 in forum Programming / Datafeeds / Tools
    Replies: 0
    Last Post: June 7th, 2006, 01:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts