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 7712435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:37:51+00:00 2026-06-01T01:37:51+00:00

I have an array that looks like that Array ( [0] => Array (

  • 0

I have an array that looks like that

Array
(
    [0] => Array
        (
            [0] => <p>How can i get the firstName values from this array? its easy with
  print_r, <strong>but I want individual values</strong></p>
            [1] => How can i get the firstName values from this array? its easy with
  print_r, <strong>but I want individual values</strong>
        )

    [1] => Array
        (
            [0] => <p>You can do:</p>
            [1] => You can do:
        )

    [2] => Array
        (
            [0] => <p>Since your array contains objects eg <code>stdClass</code>, you need to use <code>-&gt;</code> like shown above.</p>
            [1] => Since your array contains objects eg <code>stdClass</code>, you need to use <code>-&gt;</code> like shown above.
        )

)

how can i save the [1] values of every element in a string variable. What i want to get is

How can i get the firstName values from this array? its easy with
  print_r, <strong>but I want individual values</strong> You can do: Since your array contains objects eg <code>stdClass</code>, you need to use <code>-&gt;</code> like shown above.

Update: Well the array i have in the beginning is:

Array
(
    [0] => <p>try this</p>

<pre><code>foreach($x as $val)
{
echo $val-&gt;firstName;
}
</code></pre>

    [1] => <p>Since you have an array of objects, you can either access each object by the array index or loop through the array to get each seperate object.</p>

<p>Once you have the object it self, you can simply access the first name property of the object.</p>

<p>Example of looping:</p>

<pre><code>foreach ( $array as $object ) {
echo $object-&gt;firstname;
}
</code></pre>

<p>Where $array is the variable containing your array.</p>

<p>Example of accessing via array index:</p>

<pre><code>echo $array[0]-&gt;firstname;
</code></pre>

<p>OR </p>

<pre><code>$obj = $array[0];
echo $obj-&gt;firstname;
</code></pre>

    [2] => <p>Try this (assume <code>$a</code> is your array):</p>

<pre><code>echo $a[0]-&gt;firstname;
</code></pre>

    [3] => <blockquote>
  <p>How can i get the firstName values from this array? its easy with
  print_r, <strong>but I want individual values</strong></p>
</blockquote>

<p>You can do:</p>

<pre><code>foreach($yourArray as $val){
  echo $val-&gt;firstName;
}
</code></pre>

<p>Since your array contains objects eg <code>stdClass</code>, you need to use <code>-&gt;</code> like shown above.</p>

)

and it’s named answerstack then i use:

for($j=0;$j<$answerscnt;$j++){

    preg_match_all("#<p>(.*?)</p>#is",$answerstack[$j],$matches,PREG_SET_ORDER);
    foreach($matches as $item){
        $answerstack[$j]=$item[1]." ";
    }

}

what i want to accomplish is to remove <code> tags and the text between them from the first array but what i get is

Array
(
    [0] => try this 
    [1] => OR  
    [2] => Try this (assume <code>$a</code> is your array): 
    [3] => Since your array contains objects eg <code>stdClass</code>, you need to use <code>-&gt;</code> like shown above. 
)
  • 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-06-01T01:37:53+00:00Added an answer on June 1, 2026 at 1:37 am

    Looks like the result of a preg_match_all('#<p>(.*)</p>#sU') and you are trying to remove all <p> paragraphs.

    Here is another approach:

    $text = preg_replace('#<p>(.*)</p>#isU', '\1 ', $text);
    

    Here is a solution for the edited question. This code replaces all <code> tags and everything in between with an empty string:

    // iterate over each element in $answerstack
    foreach ($answerstack as &$text){
        // remove all '<code>' from $answerstack
        $text = preg_replace('#<code>(.*)</code>#isU', '', $text);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a array that looks like this Array ( [provider] => Array (
I have an array that looks like this: Array ( [0] => Array (
I have an array that looks like this, Array ( [0] => 849710414 [1]
I have an Array that looks like this: array( 0 => array( 'key1' =>
I have an array that looks like this (sample): Array ( [1600] => Array
I have an array that looks like this Array ( [0] => Array (
Hi I have an array that looks like this : Array ( [0] =>
I have an array that looks like this: Array ( [0] => Array (
Let's say I have an array that looks like this: $array[0] = 'House'; $array[1]
I have a multidimensional array that looks something like this: ourThing = array( 'id'

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.