Jump to content

Search the Community

Showing results for tags 'associative'.

  • 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 2 results

  1. Hello, Have an associative array of variable length and variable key names. The POST array can have the following structure, where [rec_n] can have one or many elements. : $_POST Array ( [rec_1769057] => on [rec_1768743] => on [ponumb] => D000000034 [strnbr] => 100 ) The 'n' is a variable SKU number and concatenated from a select statement. There are thousands of SKUs. PONUMB and STRNBR are static and will always be at the end of the array. I have an algorithm for slicing this array into two separate arrays. skuitems Array ( [rec_1769057] => on [rec_1768743] => on ) postrnbr Array ( [ponumb] => D000000034 [strnbr] => 100 ) The two arrays are then assigned to a $params array one for each update statement... $params Array ( [0] => Array ( [0] => 1768743 [1] => D000000034 [2] => 100 ) [1] => Array ( [0] => 1769057 [1] => D000000034 [2] => 100 )) I would like to accomplish the above in one go... At present the solution has and O(2) notation. Here is the algorithm that works, but seems clunky to me. if( isset($postar) && is_array($postar)) { // first order of mag. $cnt = count($postar) - 2; // total minus last two elements $postrnbr = array_slice( $postar, -2, 2 ); // always ponumb and strnbr $skuitems = array_slice($postar, 0, $cnt); // will be one or more sku items $skukeys = array_keys($skuitems); $qparams = array(); //bind params for update statement foreach($skukeys as $sku) { // second order of mag. $skusplit = explode("_",$sku); // ie Array( [0]=>rec, [1]=>1234545 ) $qparams[] = array($skusplit[1], $postrnbr['ponumb'], $postrnbr['strnbr']); } } Thanks in advance! rwhite35
  2. I'm trying to get some values from a specifc row of an array. My array has this sort of structure: $places = array( array("name" => "Cabot Cove", "area" => "12", "lat" => "-11.003", "lon" => "-151.2285", "pop" => "17"), array("name" => "Smallville", "area" => "32;", "lat" => "-19.910", "lon" => "-50.205", "pop" => "18"), array("name" => "Gotham City", "area" => "85", "lat" => "-39.9294", "lon" => "-40.199", "pop" => "14"), array("name" => "Springfield", "area" => "21.6", "lat" => "-43.9534", "lon" => "-24.2118", "pop" => "18"), ); If a variable $city is set to "Gotham CIty", for example the url of the page could be "/cities/script.php?city=Gotham+City", how do I look through the array and get the "lat" and "lon" values for just this one $city from the array?
×
×
  • 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.