Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7499139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:43:03+00:00 2026-05-29T19:43:03+00:00

Hello I have the following php code, from the output $doc I want to

  • 0

Hello I have the following php code, from the output $doc I want to take all the [content] items and put them together for use in a tag cloud. How can I extract all the [content] items into one variable?

$ch = curl_init("http://api.sysomos.com/hb/v1/heartbeat/rss?startid=0&hbrss=DUpnCTqppKjx4q1U6FXd5SWOPFUa2ltLm1haXJAYi1hbmQtcS5jby51aw..&maxC=6&max=30&hid=2535&  fTs=me&dRg=7&tab=beats&scO=Recency&");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
$doc = new SimpleXmlElement($data, LIBXML_NOCDATA);
print_r($doc);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:43:07+00:00Added an answer on May 29, 2026 at 7:43 pm

    Without further clarification, it seems you’re having trouble getting the string value of the individual <content> nodes? If so, consider the following:

    $str = '
    <xml>
      <content>content1</content>
      <somethingElse>DOH!</somethingElse>
      <content>content2</content>
      <content>content3</content>
    </xml>
    ';
    
    $doc = new SimpleXMLElement($str);
    $vals = array();
    foreach ($doc->content as $content) {
      $vals[] = (string) $content;
    }
    
    print_r($vals);
    

    This will output:

    Array
    (
        [0] => content1
        [1] => content2
        [2] => content3
    )
    

    UPDATE

    As per your comment, you could use the same tactic above with an additional implode call like so:

    $vals = implode('', $vals);
    echo $vals; // outputs: content1content2content3
    

    Or, modify the original loop to do:

    $vals = '';
    foreach ($doc->content as $content) {
      $vals .= (string) $content;
    }
    echo $vals; // outputs: content1content2content3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello and good day to all. I have the following code to retrieve from
Imagine we have 2 files, one called 1.php with the following code: <?php $hello
CODE HERE: http://jsfiddle.net/B7Y43/ Hello fello programmers, I have the following situation: My PHP-script generates
Hello I have the following php code here: $username = trim(mysql_real_escape_string($username)); $password = md5(trim(mysql_real_escape_string($password)));
I have the following pages: page1.php <?php if (isset($_GET['link'])) { session_start(); $_session['myvariable'] = 'Hello
Hello I have the following code namespace ConsoleApplication2 { class Program { static void
I have following code snippet: class ABC{ public: int a; void print(){cout<<hello<<endl;} }; int
I have the following form code: # forms.py class SomeForm(forms.Form): hello = forms.CharField(max_length=40) world
I have the following php code: index.php <?php spl_autoload_extensions(.php); spl_autoload_register(); use modules\standard as std;
I have the following code in a PHP script: <?php if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1')))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.