trixiesirisheyes Posted December 28, 2008 Share Posted December 28, 2008 In the book I'm using, Visual Quickstart, to learn PHP and MySQL, they reference this symbol in the script, but don't say what this symbol means, not even in the index, where they reference all these other symbols. I know >= is greater than or equal to, but I can't find out what => is. I even Googled the symbol and got no results. Can someone help me? I'm trying to translate the script in my head so I can understand it. At some point, I'll be creating my own scripts and not just copying what's in the book and I'll need to know what I'm doing. I'm on Chapter 2 (almost done with it) and everything else is making sense so far. Thank you in advance! Sorry to be such a n00b. Quote Link to comment https://forums.phpfreaks.com/topic/138608-solved-what-does-this-symbol-mean/ Share on other sites More sharing options...
MadTechie Posted December 28, 2008 Share Posted December 28, 2008 Its used with arrays here a basic example ie <?php $a = array(10 => "ten", 5=>"Five", "two" => 2) foreach($a as $Key => $Value) { echo "a Key=$Key with the value $Value<br>"; } ?> so you could as Key to Value Key => Value Hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/138608-solved-what-does-this-symbol-mean/#findComment-724737 Share on other sites More sharing options...
trixiesirisheyes Posted December 28, 2008 Author Share Posted December 28, 2008 But what does it *mean* ??? ++ is the increment operator - plus plus. \ means to escape. == is equal to used in comparisons. What does => mean? Is it used with *all* arrays? If not, since I don't know what it means, then how will I know when to use it? I'd be happy to read any seminal reference works on this symbol. Like I said, at some point I'm going to be writing my own code instead of copying the code from the book, and I'd like to know why I'm using a particular symbol and when I should and should not use it. Quote Link to comment https://forums.phpfreaks.com/topic/138608-solved-what-does-this-symbol-mean/#findComment-724743 Share on other sites More sharing options...
premiso Posted December 28, 2008 Share Posted December 28, 2008 It is an assignment operator. It is not used with all arrays in a sense. An array as such: <?php $array = array("test", "test2", "test3"); print_r($array); Will default that 0 => "test", 1 => "test2" and 2 => "test3" It is used with all arrays, just sometimes you do not see it. The reason you would specify it in an array would be to assign a known key to a value so you can reference it later. So that is the answer, it is used when a specific key is needed, a prime example is a database, they key would be the column and the value is the insert value IE: <?php $array = array("col1" => "value1", "col2" => value2"); foreach ($array as $colName => $value) { $cols[] = $colName; $vals[] = $values; } $cols = implode("`, `", $cols); $vals = implode("', '", $vals); $query = "INSERT INTO table_name (" . $cols . ") VALUES (". $vals. ")"; ?> etc. Quote Link to comment https://forums.phpfreaks.com/topic/138608-solved-what-does-this-symbol-mean/#findComment-724745 Share on other sites More sharing options...
trixiesirisheyes Posted December 28, 2008 Author Share Posted December 28, 2008 I understand! Thank you!! Quote Link to comment https://forums.phpfreaks.com/topic/138608-solved-what-does-this-symbol-mean/#findComment-724746 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.