0

I have a variable that looks likes this,

$rslt['expected_salary_level']

This returns a string similar to LEVEL_3, in another array that looks like this I have a set of salaries,

    Array
(
    [LEVEL_1] => Array
        (
            [nice_name] => under £10,000
            [low] => 1
            [high] => 10000
        )

    [LEVEL_2] => Array
        (
            [nice_name] => £10,000 - £15,000
            [low] => 10000
            [high] => 15000
        )

    [LEVEL_3] => Array
        (
            [nice_name] => £15,000 - £20,000
            [low] => 15000
            [high] => 20000
        )

    [LEVEL_4] => Array
        (
            [nice_name] => £20,000 - £25,000
            [low] => 20000
            [high] => 25000
        )

    [LEVEL_5] => Array
        (
            [nice_name] => £25,000 - £30,000
            [low] => 25000
            [high] => 30000
        )

    [LEVEL_6] => Array
        (
            [nice_name] => £30,000 - £40,000
            [low] => 30000
            [high] => 40000
        )

    [LEVEL_7] => Array
        (
            [nice_name] => £40,000 - £50,000
            [low] => 40000
            [high] => 50000
        )

    [LEVEL_8] => Array
        (
            [nice_name] => £50,000 - £100,000
            [low] => 50000
            [high] => 100000
        )

    [LEVEL_9] => Array
        (
            [nice_name] => £100,000 or more
            [low] => 100000
            [high] => 9999999
        )

    [LEVEL_VOLUNTARY] => Array
        (
            [nice_name] => Voluntary
            [low] => 
            [high] => 
        )

    [LEVEL_UNSPECIFIED] => Array
        (
            [nice_name] => Not specified
            [low] => 
            [high] => 
        )

)

How do I get at the associated nice name?

1
  • 4
    What's wrong with $thatArray['LEVEL_3']['nice_name']? Commented Apr 15, 2010 at 14:52

2 Answers 2

8

If I understand you correctly, $rslt['expected_salary_level'] returns the key for this array in your example. Assuming that this array is called $array, I think this is what you want:

$array[$rslt['expected_salary_level']]['nice_name']
Sign up to request clarification or add additional context in comments.

Comments

0

I think this is a simple way to get array to array key values :

$own_array_result = $rslt['expected_salary_level']['LEVEL_3']['nice_name'];

echo $own_array_result;

OUTPUT => £15,000 - £20,000

1 Comment

plz format you ans Markdown help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.