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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:12:20+00:00 2026-06-09T01:12:20+00:00

Here is how I set my Array: $Post_Cat_Array = array(); while($row = mysql_fetch_array( $result

  • 0

Here is how I set my Array:

 $Post_Cat_Array = array();
 while($row = mysql_fetch_array( $result )) {
 $Post_Cat_Array[$row['type_id']] = $row['type_name'];}

in this function I need to get the type_id(key) of a specific type_name(value)

function NameToID($input){
echo array_search($input, $Post_Cat_Array); 
}

and I call the function like this :

NameToID($_POST['type']);

But it’s not working. It doesn’t echo anything. I am sure the $_POST['type'] contains correct value.

note:value of $_POST['type'] is in arabic. same with all values of the array.

  • 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-09T01:12:22+00:00Added an answer on June 9, 2026 at 1:12 am

    It seems that $Post_Cat_Array is out of scope. Modify your function:

    function NameToID($input, $arr){
      echo array_search($input, $arr); 
    }
    

    and then:

    NameToID($_POST['type'], $Post_Cat_Array);
    

    From PHP Variable scope:

    This script will not produce any output because the echo statement
    refers to a local version of the (…) variable, and it has not been
    assigned a value within this scope.

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

Sidebar

Related Questions

Here is my data returned from a CMS function: array ( 0 => stdClass::__set_state(array(
I get the following error in my image upload code: Warning: getimagesize(Array) [function.getimagesize]: failed
The global $post variable is not set here. How do I set it? function
I set out to generate a array containing a 12-month calendar starting on this
How can i find all subsets of a set using c#? here set is
I just found an icon set here: http://www.archetype-inc.com/yard/fundamentals/icons/ I've been looking for something like
Here is dataset: set.seed(123) myd <- data.frame (class = rep(1:4, each = 100), yvar
I am developing w php web site. Here I have set a php cookie
Here's my batch script: @echo off cls set SOURCE=svn://vcrep/UXP/ercpac/trunk/ set SVN=C:\Program Files\TortoiseSVN\bin %SVN%\TortoiseProc.exe /command:update
Here is the problem from code chef : A set of N dignitaries have

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.