Put Any Php Codes Here If You Wish Thank-you JamieHxD
Hi Jamie.
What code are you looking for? I wonder if some links to basic, or getting started, tutorials would be better for you.
Iāll have a look around for some, but maybe other members know of some?
Anthony.
Thereās Michael Morrisā 'PHP Basicsā thread here at SitePoint, you should read that. It points to the [URL=āhttp://www.php.net/manual/en/index.phpā]PHP Manual a lot too, however the guide at the manual isnāt too good IMO.
Ok Thank-you Iāve Looked At It And I Donāt Get Any Of It :s
Is there a part of the language you want to learn first? Strings, Arrays ā¦
arrayās Please.
Sure.
Make sure you (try to) read the manual section on arrays too, but here you go.
<?php
/*
Declare an array
*/
$array = array();
/*
Add some elements
*/
$array[] = 'jamie';
$array[] = 'anthony';
$array[] = 'sitepoint';
/*
Array indicies start at 0. So,
jamie is at 0, anthony is at 1
and sitepoint is at 3.
*/
/*
display the item at index 1
*/
echo $array[1], PHP_EOL; #anthony
/*
display the item at index 0
*/
echo $array[0], PHP_EOL; #jamie
/*
You can also display them all
using a loop, or 'foreach'.
*/
foreach($array as $name){
echo $name, PHP_EOL;
}
Hereās another variation.
<?php
/*
Declare an array
*/
$users = array();
/*
Add some elements
*/
$users['jamie'] = 13;
$users['anthony'] = 31;
foreach($users as $name => $age){
echo $name, ' is ', $age, PHP_EOL;
}
/*
jamie is 13
anthony is 31
*/
Ahh Ok Thank-You I Think Iāve Got The Jist Now.
Iāve Eited Youāre Code As It Came Up With Anthony Jamie Jamie Anthony Sitepoint so i took out the echo to sort it out. Here this one.
<?php
$array = array();
$array[] = 'jamie';
$array[] = 'anthony';
$array[] = 'sitepoint';
foreach($array as $name){
echo $name, PHP_EOL;
}
That looks good.
How do you think you can reverse the array so that the output is sitepoint, anthony, jamie without altering $array.
like this
<?php
$array = array();
$array[] = 'sitepoint';
$array[] = 'anthony';
$array[] = 'jamie';
foreach($array as $name){
echo $name, PHP_EOL;
}
Nope, youāve altered $array.
<?php
$array = array();
$array[] = 'jamie';
$array[] = 'anthony';
$array[] = 'sitepoint';
/* you can change anything below here */
Take a look at this list of array functions and read the description, are there any there that sound like they maybe useful?
absolutely no idea. :?
Try thisā¦
I Can Not Do It.
Ahhh Ha Iāve Found It. Here
<?php
$array = array();
$array[] = 'jamie';
$array[] = 'anthony';
$array[] = 'sitepoint';
$trans = array("jamie" => 3, "anthony" => 2, "sitepoint" => 1);
$trans = array_flip($trans);
print_r($trans);
Not quite.
You were on the right track though!
<?php
$array = array();
$array[] = 'jamie';
$array[] = 'anthony';
$array[] = 'sitepoint';
/* you can change anything below here */
foreach(array_reverse($array) as $name){
echo $name, PHP_EOL;
}
oh ok thank-you.