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

  • Home
  • SEARCH
  • 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 8321797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:09:04+00:00 2026-06-08T23:09:04+00:00

I have array like array( v=>1, u=>8, v1=>45, v123=>12 ); In my program i

  • 0

I have array like

array(
    "v"=>1,
    "u"=>8,
    "v1"=>45,
    "v123"=>12
);

In my program i need to check whether the array contains an element whose key starts with v followed by numbers.My array is very large ,so that I do not prefer iteration.Is there any other efficient way to do this.I expect something like isset(arr[regex]);

  • 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-08T23:09:05+00:00Added an answer on June 8, 2026 at 11:09 pm

    You can use array_filter (http://php.net/manual/en/function.array-filter.php)

    first creat a callback function:

    function getKeys($n){
     return preg_match('/^v[0-9]+$/', $n);
    }
    

    Then run the array_filter:

    $arr = array(
        "v"=>1,
        "u"=>8,
        "v1"=>45,
        "v123"=>12
    );
    
    $newArr = array_filter(array_keys($arr), "getKeys");
    

    You can see the result with the right array_keys:

    print_r($newArr);
    

    If you have a result this statement should be true:

    echo count($newArr) > 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to find whether a string array contains some part of string? I have
I have an array like $arr = array('key1' => 'hello'); Now I need to
I have array like this: array('1224*', '543*', '321*' ...) which contains about 17,00 "masks"
I have array like this: $path = array ( [0] => site\projects\terrace_and_balcony\mexico.jpg [1] =>
Hello i have array like this [0] => Array ( [ExamMonth] => Array (
An array is defined of assumed elements like I have array like String[] strArray
I have array result like this: Array ( [0] => stdClass Object ( [id_global_info]
I have an array like this var array = [{ order: 3, sub -
I have an array like: errors = [ {...}, {...}, {...} ] It's an
I have an array like this one $state[1]='FG'; $state[2]='BU'; $state[3]='CA'; ... $state[150]='YT' What I

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.