[ciapug] Array building
Chris Van Cleve
ciapug@cialug.org
Wed, 11 May 2005 16:10:36 -0500
Ding! We have a winner. My conundrum for the evening to research then=20
is this:
The 4 places I found array building examples had the keywords in=20
quotes. PHP ignores whitespace as all good languages do. Why then did=20
the extra spaces impede parsing? (BTW - Those were spaces. If they were=20=
tabs in my e-mail I have to spank my mail client for misbehaving)
Chris VC
On May 11, 2005, at 4:04 PM, Bryan Baker wrote:
> I got a parse error too, but then I got rid of the quotes arounnd the=20=
> keywords and the tabs before the =3D> and now it runs fine.
>
>
> <?php
> // Build array of meta information
> $meta =3D array (
> keywords =3D> 'Some text',
> htdig-keywords=A0=3D> 'Some text',
> description =3D> 'Some text',
> author =3D> 'Some text',
> revisit-after=A0=3D> 'Some text',
> distribution =3D> 'Some text',
> generator =3D> 'Some text',
> rating =3D> 'Some text'
> );
>
> echo "<pre>";
> echo var_dump($meta);
> echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
\n";
> print_r ($meta);=09
> echo "</pre>";
>
> ?>
>
> =3D=3D=3D output =3D=3D=3D
>
> array(7) {
> ["keywords"]=3D>
> string(9) "Some text"
> [0]=3D>
> string(9) "Some text"
> ["description"]=3D>
> string(9) "Some text"
> ["author"]=3D>
> string(9) "Some text"
> ["distribution"]=3D>
> string(9) "Some text"
> ["generator"]=3D>
> string(9) "Some text"
> ["rating"]=3D>
> string(9) "Some text"
> }
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> Array
> (
> [keywords] =3D> Some text
> [0] =3D> Some text
> [description] =3D> Some text
> [author] =3D> Some text
> [distribution] =3D> Some text
> [generator] =3D> Some text
> [rating] =3D> Some text
> )
>
> On May 11, 2005, at 4:00 PM, Chris Van Cleve wrote:
>
>> I just uploaded it to another server and I get the same parse error i=20=
>> experienced before on my intranet box:
>>
>> Parse error: parse error, unexpected T_STRING, expecting ')' in=20
>> /home/dreamsc/public_html/array_test.php on line 4
>>
>> Line 4 =3D 'keywords' =3D> 'Some text',
>>
>> I'm so confused. Trying a 3rd server to see what happens.
>>
>> Chris VC
>>
>> On May 11, 2005, at 3:53 PM, Dave J. Hala Jr. wrote:
>>
>>> Runs fine here. Here's the output:
>>>
>>> array(8) {
>>> ["keywords"]=3D>
>>> string(9) "Some text"
>>> ["htdig-keywords"]=3D>
>>> string(9) "Some text"
>>> ["description"]=3D>
>>> string(9) "Some text"
>>> ["author"]=3D>
>>> string(9) "Some text"
>>> ["revisit-after"]=3D>
>>> string(9) "Some text"
>>> ["distribution"]=3D>
>>> string(9) "Some text"
>>> ["generator"]=3D>
>>> string(9) "Some text"
>>> ["rating"]=3D>
>>> string(9) "Some text"
>>> }
>>> On Wed, 2005-05-11 at 15:46, Chris Van Cleve wrote:
>>>> Unfortunately, that's what I did. here is the code of the full file
>>>> which turns up blank. (I'm hoping to test it on another web server
>>>> later)
>>>>
>>>> <?php
>>>> // Build array of meta information
>>>> $meta =3D array (
>>>> 'keywords' =3D> 'Some text',
>>>> 'htdig-keywords' =3D> 'Some text',
>>>> 'description' =3D> 'Some text',
>>>> 'author' =3D> 'Some text',
>>>> 'revisit-after' =3D> 'Some text',
>>>> 'distribution' =3D> 'Some text',
>>>> 'generator' =3D> 'Some text',
>>>> 'rating' =3D> 'Some text'
>>>> );
>>>>
>>>> echo "<pre>";
>>>> echo var_dump($meta);
>>>> echo "</pre>";
>>>>
>>>> ?>
>>>>
>>>> On May 11, 2005, at 3:25 PM, Dave J. Hala Jr. wrote:
>>>>
>>>>> Try this:
>>>>>
>>>>>
>>>>> echo "<PRE>";
>>>>> echo var_dump($decoded_value);
>>>>> echo "</PRE>";
>>>>>
>>>>>
>>>>> On Wed, 2005-05-11 at 14:27, Chris Van Cleve wrote:
>>>>>> FInally getting back around to this. To answer some of the below
>>>>>> questions:
>>>>>>
>>>>>> 1. This is the first thing in the file. The only preceeding code=20=
>>>>>> is
>>>>>> <?php
>>>>>>
>>>>>> 2. I placed the code in a stand-alone file, with a=20
>>>>>> var_dump($meta) and
>>>>>> I get a blank page. Go figure.
>>>>>>
>>>>>> Chris VC
>>>>>>
>>>>>> On Apr 14, 2005, at 12:28 PM, Tony Bibbs wrote:
>>>>>>
>>>>>>> Odds are you are missing an ')' or ';' in the lines preceeding=20=
>>>>>>> the
>>>>>>> code snippet you gave.
>>>>>>>
>>>>>>> --Tony
>>>>>>>
>>>>>>> Laith wrote:
>>>>>>>
>>>>>>>> I think you have some other issue in the fime that is confusing
>>>>>>>> things.
>>>>>>>>
>>>>>>>> when I place that code into a test.php I get no errors and I =
can
>>>>>>>> var_dump($meta)
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Chris Van Cleve wrote:
>>>>>>>>
>>>>>>>>> No line 3 is:
>>>>>>>>>
>>>>>>>>>>> 'keywords' =3D> 'Some text',
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Apr 13, 2005, at 12:30 PM, Dave J. Hala Jr. wrote:
>>>>>>>>>
>>>>>>>>>> It looks ok to me. Is $meta =3D array on line three?
>>>>>>>>>>
>>>>>>>>>> On Wed, 2005-04-13 at 12:18, Chris Van Cleve wrote:
>>>>>>>>>>
>>>>>>>>>>> I have never had a reason to hand build an array before, and=20=
>>>>>>>>>>> now
>>>>>>>>>>> that I
>>>>>>>>>>> have a reason I cannot seem to get it to work. Is there any
>>>>>>>>>>> reason
>>>>>>>>>>> the
>>>>>>>>>>> following is not valid?
>>>>>>>>>>>
>>>>>>>>>>> // Build array of meta information
>>>>>>>>>>> $meta =3D array (
>>>>>>>>>>> 'keywords' =3D> 'Some text',
>>>>>>>>>>> 'htdig-keywords' =3D> 'Some text',
>>>>>>>>>>> 'description' =3D>'Some text',
>>>>>>>>>>> 'author' =3D> 'Some text',
>>>>>>>>>>> 'revisit-after' =3D> 'Some text',
>>>>>>>>>>> 'distribution' =3D> 'Some text',
>>>>>>>>>>> 'generator' =3D> 'Some text',
>>>>>>>>>>> 'rating' =3D> 'Some text'
>>>>>>>>>>> );
>>>>>>>>>>>
>>>>>>>>>>> It's not single vs double quotes. It throws the same error=20=
>>>>>>>>>>> either
>>>>>>>>>>> way:
>>>>>>>>>>>
>>>>>>>>>>> [error] PHP Parse error: parse error, unexpected T_STRING,
>>>>>>>>>>> expecting
>>>>>>>>>>> ')' in /path/to/document/index.php on line 3
>>>>>>>>>>> _______________________________________________
>>>>>>>>>>> ciapug mailing list
>>>>>>>>>>> ciapug@cialug.org
>>>>>>>>>>> http://cialug.org/mailman/listinfo/ciapug
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --=20
>>>>>>>>>>
>>>>>>>>>> Open Source Information Systems (OSIS)
>>>>>>>>>> Dave J. Hala Jr. <dave@osis.us>
>>>>>>>>>> 641.485.1606
>>>>>>>>>>
>>>>>>>>>> _______________________________________________
>>>>>>>>>> ciapug mailing list
>>>>>>>>>> ciapug@cialug.org
>>>>>>>>>> http://cialug.org/mailman/listinfo/ciapug
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> ciapug mailing list
>>>>>>>>> ciapug@cialug.org
>>>>>>>>> http://cialug.org/mailman/listinfo/ciapug
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> ciapug mailing list
>>>>>>>> ciapug@cialug.org
>>>>>>>> http://cialug.org/mailman/listinfo/ciapug
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> ciapug mailing list
>>>>>>> ciapug@cialug.org
>>>>>>> http://cialug.org/mailman/listinfo/ciapug
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> ciapug mailing list
>>>>>> ciapug@cialug.org
>>>>>> http://cialug.org/mailman/listinfo/ciapug
>>>>> --=20
>>>>>
>>>>> Open Source Information Systems (OSIS)
>>>>> Dave J. Hala Jr. <dave@osis.us>
>>>>> 641.485.1606
>>>>>
>>>>> _______________________________________________
>>>>> ciapug mailing list
>>>>> ciapug@cialug.org
>>>>> http://cialug.org/mailman/listinfo/ciapug
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> ciapug mailing list
>>>> ciapug@cialug.org
>>>> http://cialug.org/mailman/listinfo/ciapug
>>> --=20
>>>
>>> Open Source Information Systems (OSIS)
>>> Dave J. Hala Jr. <dave@osis.us>
>>> 641.485.1606
>>>
>>> _______________________________________________
>>> ciapug mailing list
>>> ciapug@cialug.org
>>> http://cialug.org/mailman/listinfo/ciapug
>>>
>>>
>>
>> _______________________________________________
>> ciapug mailing list
>> ciapug@cialug.org
>> http://cialug.org/mailman/listinfo/ciapug
>>
>>
> --
> Bryan Baker
> Technology Advocate
> Iowa Legal Aid
> Suite 230
> 1111 9th Street
> Des Moines, Ia 50314-2527
>
> (515) 243-2151 (x1635)
>
> http://www.iowalegalaid.org
> bbaker@iowalaw.org
>