understanding php html.

hai all. i am just starting to lean php. the following code I is the working code. i thought that code II should also work. but it doesnt work. if any one could explain me why i will be thankful. this will help me understand how php and html work with each other. thank you in advance. here are the codes and results

code I

<?php $array1=array(4,8,15,16,23,42); ?>
<?php print_r($array1); ?>

the result

Array
(
[0] => 4
[1] => 8
[2] => 15
[3] => 16
[4] => 23
[5] => 42
)

code II

<?php $array1=array(4,8,15,16,23,42); echo "
" . print_r($array1) . "
"; ?>

result

Array ( [0] => 4 [1] => 8 [2] => 15 [3] => 16 [4] => 23 [5] => 42 )

1


i am sorry if its just a spelling mistake but am really new.

Dear, its giving you the perfect output of your code the 1 you are seeing in the last is also your typing mistake. See echo “

” . print_r($array1) . “
”; this is where you are getting 1 in output

;D blackleo. thanq

Sponsor our Newsletter | Privacy Policy | Terms of Service