Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
is it possible to use array for internal like this?
$b = array( 'a' => 'Adam', 'b' => $b['a'].' and eve' );
$b
NOTICE Undefined variable: b on line number 5
No this is not possible, what you can do is this:
$b = array( 'a' => 'Adam' ); $b['b'] = $b['a'] . ' and eve';
Add a comment
No that is not possible because the array $b hasn't been created yet when you try to add
'b' => $b['a'];
Instead you should create the array $b, then add the other element. Like so:
$b = array('a' => 'Adam'); $b['b'] = $b['a'] . ' and eve';
No not possible, as doing so would produce E_NOTICE : type 8 -- Undefined variable: b -- at line X _where X is the where you are 'b' => $b['a'] assigning a value to b
'b' => $b['a']
b
No, It's not possible, It will give Error like "Undefined variable: b". If you want to perform anyway, use this one
$b = array('a' => 'Adam'); $b['b'] = $b['a'];
Required, but never shown
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.
Explore related questions
See similar questions with these tags.
$bwon't be defined yet.NOTICE Undefined variable: b on line number 5pretty simple