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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:38:02+00:00 2026-06-09T02:38:02+00:00

I am trying to get strings from a long array value. for example $array[1]=’this

  • 0

I am trying to get strings from a long array value.

for example

$array[1]='this is a good day. The number:1, class:math';
$array[2]='this is a bad day. The number:2, class:english';
$array[3]='this is a fine day. The number:3, class:physics';

I want to get the number:1 or class:math strings out of the array.

I tried

echo array_search('number:1',$array);

but it gave me nothing. I was wondering if there are better ways to do this. Thanks a lot!

  • 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-09T02:38:03+00:00Added an answer on June 9, 2026 at 2:38 am

    I guess you’re searching for something like the following. Searching for a needle inside of values of arrays.

    <?php
    function array_search_inline($needle, $haystack) {
        foreach ($haystack as $key => $value) {
            if (strpos($value, $needle) !== false) {
                return $key;
            }
        }
        return false;
    }
    ?>
    

    Note: array_search simply compares the array’s values and does not search inside of them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a long value from a String containing a Facebook ID,
I am trying to compare two strings I get from a password form in
I am trying to write a regex to get the numbers from strings like
I'm trying to figure out how to get a string from an array starting
I'm trying to get a std::string from my database using mysql connexion Here is
I'm trying to get the query string from a string (not the current URL).
I'm trying to get a json string back from my controller, that is prefill-values
I am trying to get a date object from a string from an input.
I'm trying to get the JSON object from a JSON outputted string from a
I'm trying to convert date formats in javascript. I get a string from a

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.