Search results for 'array'. 3 post(s) found.

  1. 2007/10/16 How to declare array in PHP like C/C++
  2. 2007/08/26 IsIn For Arrays
  3. 2007/08/26 Array_count_values
2007/10/16 09:42

How to declare array in PHP like C/C++


simple PHP array declaration:

<?php
// array starting from index 1
$notes = array(1 => 'Do', 'Re', 'Me');

//print out array
print_r($notes);
?>

Another posts included in "PHP"

How to pass variables via url (0)2007/10/16
How to send email in PHP ? (0)2007/10/16
PHP Switch Example (0)2007/10/16
PHP date and time formatting (0)2007/10/16
How to redirect browser in PHP ? (0)2007/10/16
How to get current filename as variable ? (0)2007/10/16
email validation, simple (0)2007/10/16
How to ban / block IP addresses (0)2007/10/16
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 01:41 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 09:54 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:42 delete

    moneyideas

2007/08/26 21:01

IsIn For Arrays


Coming from a Python to JavaScript I was a bit miffed by the lack of functions for some things. I once tried to use am isIn function on an array and found it to be absent. Or at at least it was at the time. This was some time ago back in the early days of JS. So I wrote this little snippet and I think many beginners might find it useful and maybe use it even if they didn’t know they needed it. The function takes two arguments an array and a value. The value is first and the array second. Why? Simple “Hey Marilyn is the burrito still in the fridge?” What is this man talking about? Simple the idea that this function is essentially a question. It’s asking if something is in something else. I’ve yet to pose the question “Hey, Marilyn does the fridge have a burrito in it?” It’s rather awkward and no one likes that so to remember parameter orders I like to put them in the order that they would be if I asked it as a question. The internal names are basically what they are. thearray is “the array” and theValue is “the value” you’re looking for. checkValue is the iteration of the loop and thus what value in “the array” or thearray you’re looking for.

function isIn(theValue, thearray) {
    for(checkValue = 0; checkValue < thearray.length-1; checkValue++){
        if((thearray[checkValue] == theValue))
            return true;
    }
    return false;
}

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 05:07 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 13:53 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:43 delete

    moneyideas

2007/08/26 01:59

Array_count_values


This code prints array count values

<?
$array = array(1,"hello",1,"world","hello");

print_r(array_count_values($array));

?>

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 04:45 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 13:37 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:43 delete

    moneyideas