Jump to content

Search the Community

Showing results for tags 'array_search'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 3 results

  1. Hey everyone!!! It has been years since I have had to opportunity to post on here. I am, however, getting back into development. I am running into an issue and I was looking for some help. Here is the code: $years = array(); //Build the years array, we can only go forward 3 years, backwards 1 year. $sYear = date(Y, strtotime('-1 years')); //Start Year $eYear = date(Y, strtotime('+3 years')); //End Year while($sYear < $eYear){ array_push($years, $sYear); //Add each year that fits to the array $sYear++; } //In order for us to make sure we have clean parameters for our jQuery calls later //We have to make sure that our year variable usage is consistant throughout. //If our case, we are passing the full 4 digit year as am INT = $curYear $curYear = clean($_GET['curYear']); print "Before anything: curYear = $curYear <br><br><br>"; if($curYear == "" || $curYear == null){ //No Year set, use current print "empty or null<br>"; exit; $curYear = date(Y); }elseif(!is_numeric($curYear)){ //Not even a number lol print "not number<br>"; $curYear = date(Y); }elseif($aSearch = in_array($curYear, $years, true)){ print "valid year<br>" . $years[$aSearch]; //It isn't in our array of valid years //$curYear = date(Y); }else{ //all else failed $curYear = date(Y); print "Failed all tests.<br>"; } //Should be a good year for our calendar by this point. exit; I am passing the variable curYear in the url: index.php?curMonth=July&curYear=2013 For some reason, it outputs: Before anything: curYear = 2013 Failed all tests. printing the $years array gets: Array ( [0] => 2013 [1] => 2014 [2] => 2015 [3] => 2016 ) I think you get the just of what I am looking for here. Thanks for the help!!
  2. I have this array and I need to search it for the 'id' for a specific value $id. What i'm trying to do is get the position in the array of the id i'm searching for. I have tried $position = array_search($id, $rows); but I get bool false The contents of $rows (taken from MySQL database) is array( { [0]=> array(1) { ["id"]=> string(2) "24" } [1]=> array(1) { ["id"]=> string(2) "22" } [2]=> array(1) { ["id"]=> string(2) "12" } [3]=> array(1) { ["id"]=> string(2) "11" } [4]=> array(1) { ["id"]=> string(1) "8" } [5]=> array(1) { ["id"]=> string(1) "6" } [6]=> array(1) { ["id"]=> string(1) "5" } [7]=> array(1) { ["id"]=> string(1) "4" } }
  3. Hello, I am trying to unset from array using array_search, it's working, except the first array value "a+" is not working $bloodType_list = ['a+','a-','b+','b-','o+','o-','ab+','ab-']; if($key = array_search('a+',$bloodType_list)){ unset($bloodType_list[$key]); } foreach($bloodType_list as $bloodType_lists){ echo $bloodType_lists."<br>"; }
×
×
  • 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.