Jump to content

[SOLVED] => What does this symbol mean?


trixiesirisheyes

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.