0

I get some links from feed with this code on simplepie :

 if ($check) :
  foreach ($feed->get_items(0,3) as $item):
  $links = $item->get_permalink();
  echo $links;
 endforeach; endif;

thats result me:

http://link1....
http://link2....
http://link3....

i want to put each link in separate variable like :

$links1 = 'http://link1....';
$links1 = 'http://link2....';
$links1 = 'http://link3....';

thanks , mori

1
  • I want to show content of each links with "simple_html_dom" after that link retrieved. Commented Jun 7, 2011 at 7:15

3 Answers 3

3
$i = 0;
foreach($feed->get_items(0,3) as $item)) {
    ${'link' . ++$i} = $item->get_permalink();
}
Sign up to request clarification or add additional context in comments.

Comments

3

Maybe what you want is array variable?

try this:

 if ($check) :
   foreach ($feed->get_items(0,3) as $item):
     $links[] = $item->get_permalink();
 endforeach; endif;

Comments

0
if ($check) :
$i=0;
  foreach ($feed->get_items(0,3) as $item):
  $links.$i = $item->get_permalink();
  echo $links.$i;
$i++;
 endforeach; endif;

I think it may works...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.