Forum Moderators: coopster

Message Too Old, No Replies

How to set array without an error?

         

toplisek

1:14 pm on Apr 5, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have error in array content:
'mystuff' => array(
'myproject' => 'text1 | text2 | text3 | text4 | text5'.$mvariable;

How to set correct PHP code without showing an error like:
expecting ')

rainborick

3:24 pm on Apr 5, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The code you posted is apparently just a fragment and doesn't provide enough information to suggest the correct syntax. Try posting more of your original code so we can see what you're trying to do.

eelixduppy

3:26 pm on Apr 5, 2011 (gmt 0)



So you want something like this?


$array = array(
'mystuff' => array(
'myproject => 'text1 | text2 | text3 | text4 | text5'.$mvariable
)
);


What you posted doesn't look like the full PHP code to me, so if you want to elaborate then maybe I can be of more assistance.

toplisek

8:14 am on Apr 6, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, I made mistake. Sorry. It has other code and it is missing , at the end.

rocknbil

4:26 pm on Apr 6, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Look at your original, you have a semicolon, end of statement in the middle of an array:

'mystuff' => array(
'myproject' => 'text1 | text2 | text3 | text4 | text5'.$mvariable;

elixduppy's has a missing quote too after myproject, but the idea is correct. :-) Being an array, you comma separate the members.

$array = array(
'mystuff' => array(
'myproject' => 'text1 | text2 | text3 | text4 | text5'.$mvariable,
'myramblings' => 'some stuff',
'mygirls' => 'more of your stuff'
),
// second array member
'yourstuff' => array(
'myproject' => 'achoo'.$mvariable,
'myramblings' => 'gazoonteight',
'mygirls' => 'thank you'
)
);

The exception of course is the last member in either array set (parent and child).

toplisek

5:56 am on Apr 7, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I have array and explode function. How to set this function?
'mykey' => array(
'myfolder' => array(
'mysentence1' => 'WORLD1 | WORLD2 | WORLD3 | WORLD4 | WORLD5',
),
I like to add explode function of this mysentence
$mywords1 = explode('| ', $myfirstword1 [0]);

Is this possible to achieve within Array?