We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12658
    • 9 Posts
    Hello all!

    I have FeedX importing a feed to my website. Some of the feeds have a string of text I would like removed.

    The line of code I need removed is:
    <p><a href="http://www.flickr.com/people/customname/">Username</a> posted a photo:</p>

    I don’t know php very well (if I did I wouldn’t be asking wink). I looked it up and was fairly confused about arrays.

    I would guess I need to do something similar to the following:
      $search = array('|(http://[^ ]+)|', '|@([\w_]+)|', '|#([A-Za-z0-9-_]+)|');
      $replace = array('<a href="$1">$1</a>', '<a href="http://twitter.com/$1">@$1</a>', '<a href="http://search.twitter.com/search?q=%23$1">#$1</a>');
      $output = preg_replace($search, $replace, $output);
    
      return substr($output,10);
    

    It should be easier than the above because the string I am removing is always the same.

    Any help with this and/or a clearer explanation of arrays than what’s on the php documentation would be most appreciated.

    Thanks smiley
      • 20413
      • 2,877 Posts
      If that’s in the beginning of the output, calculate how many characters
      "<p><a href="http://www.flickr.com/people/customname/">Username</a> posted a photo:</p>"
      contains and use that number (instead of 10) in a modifier simple like this:
      $string = substr($output,10);
      return $string;

      If you name it phx:flickr then use [+DESCRIPTION:flickr+] in your ITEM tpl.

      ---Edited---
        @hawproductions | http://mrhaw.com/

        Infograph: MODX Advanced Install in 7 steps:
        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
        • 12658
        • 9 Posts
        Thanks, worked perfectly. grin