Jump to content

Search the Community

Showing results for tags 'array'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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 (Dreamweaver, Zend, 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

  1. Hi, simply put; I am having a very difficult time trying to find a way I can Match (partial?) strings, comparing to 2 arrays (the matches have different [Keys].) for example: $abs="Bob Rob Sue"; $abt="sometext Bob1:2 moretext Sue3:4 othertext Rob5:6 etc"; how can I put into code, when "Bob1:2" is used, it finds a match of "Bob", and assigns the complete string of "Bob1:2" ? The course I have been trying I get Bob, Rob, and Sue.. but the #numbers# are in the wrong place. ie; it will result with "Sue5:6" I understand its a [key] issue, using array_intersect along with some ex
  2. I have an existing PHP array ($products) with various fields in it.... id / title / description / link / image link etc. etc. as per requirements for a Google Products feed (https://support.google.com/merchants/answer/7052112). My issue is that, for clothing, Google want a separate record for each size available. My array includes the "size" field as a comma separated list e.g. 6,8,10,12,14 or XS,S,M,L,XL etc. etc. So before creating the feed (a text file, which is currently outputting fine except for the size field issue) I need to duplicate each id where there's more than 1 size in
  3. NOTE - Please read the information first as it contains important information to understand the problem. Rules → • There are 9 Columns(C1,C2,C3,C4,C5,C6,C7,C8,C9) [ Max columns will be 9] • The number of Rows can vary from 3,6,9,12,15,18 (Max). In this case Number of Rows shall be 12 Number of Rows = No of Tickets (Max Allowed 6) x Rows Per Ticket (Max Allowed 3). Thus, Max Rows can be 18 • Each Row is required to have 4 Blank Spaces and 5 Filled with Numbers • All numbers available in the Column Array have to be utilized • This configuration of an shall crea
  4. I have a foreach loop that returns 5 users. I basically want to show only 1 of the 5 users. Every time that loop is run, it should show a random user of the 5, as oppose to the same user every single time. How can that be done? This is my query so far. $find_user = $db->prepare("SELECT user_id FROM users ORDER BY user_id ASC"); $find_user->execute(); $result_user = $find_user->fetchAll(PDO::FETCH_ASSOC); if(count($result_user) > 0) { foreach($result_user as $row) { $user_id = trim($row['user_id']); var_dump($user_id); } }
  5. Hello, Im hoping to get help from here, i have arrays of text fields that i need to get sums,.. <div class='fldgroup'> <input type="text" name="fld[0]"> <input type="text" name="fld[0]"> <input type="text" name="fld[0]"> <input type="text" name="sumfld[0]"> <button>Add Another Field</button> <input type="text" name="fld[1]"> <input type="text" name="fld[1]"> <input type="text" name="fld[1]"> <input type="text" name="sumfld[1]"> <button>Add Another Field</button> </div> <butto
  6. I have an array of data where a user can delete names and their value, like below. This is what the array looks like after a couple are deleted: [0] => Array ( [name1] => [value1] => [name2] => Name [value2] => 10 [name3] => Another name [value3] => 20 [name4] => [value4] => [name5] => And Another [value5] => 40 ) I need to dynamically move up the values if any are deleted, so the array becomes: [0] => Array ( [name1] => Name [valu
  7. I currently have an array that I've built that dumps like this: 0 => array:11 [▼ "category_code" => "123" "category_name" => "Testing" "category_description" => "This is a test category" 19738 => array:5 [▼ "identifier" => "720368842943" "description" => Test Description One "count" => 4 "details" => array:2 [▼ 0 => array:3 [▼ "detail_code" => "2751" "detail_code2" => "43" "detail_specifier" => "Detail One" ] 1 => array
  8. I asked this question before and I did receive the answer I was looking for. But now I realize something. It only works for the first result. Let me explain. I am using this API. https://block.io/api/simple/php $get_address = $block_io->get_transactions(array('type' => 'received', 'addresses' => $my_wallet)); $api_amount = $get_address->data->txs[0]->amounts_received[0]->amount; $api_recp = $get_address->data->txs[0]->amounts_received[0]->recipient; $api_trans_id = $get_address->data->txs[0]->txid; $api_sender_id
  9. I need to add a second value to my associative array. $lines[substr($line, 69, 5)] = substr($line, 117, 2); I need to add substr($line, 91, 10)
  10. I'm using WordPress and Tribe's Event Calendar and Event ticket plus plugins. Their website is http://theeventscalendar.co.uk. I've been using their forums but it's taking a while to sort this out, so though someone on here might be able to help. I've got an array that I need to echo out part of. Inside each key (0, 1, 2, 3 and so on) there are numerous parts like ["ID"], ["name"] and so on. I want to echo out the ["name"] part of the key. I have a var dump for 10 keys in the array, each of which have their own ["name"] set. In the situation I'm using it, it will always have just
  11. I am having trouble with an array. Don't know to much about them. I have a form on create.php where they can choose multiple items for there trade. On the create.pro.php is where I want it to put all the checked items from create.php together separated by commas into my database. (That way I can explode them later to get them separately - correct?) create.php $stmt = $mysqli->prepare("SELECT id, owner, item_id, uses_left FROM useritems WHERE owner = ? ORDER BY item_id"); $stmt->bind_param('s', $userid); $stmt->execute(); $stmt->store_result(); $countitems = $stmt->num_rows
  12. Hi, I've inherited some code on a system from another person. I'll be the first to admit that I'm not a PHP pro, I am self taught, and use it sparingly for personal projects mainly. So this is a bit beyond my skill level, and I was hoping for some advice: The system is a glorified calendar, with a lot of our own data being slapped on top of it and presented nicely. The issue I have thoguh is that due to the way the calendar is generated, I cant make the height of the days move dynamically based on what content gets dropped into each day on the calendar. If one day is busy and has 8 eve
  13. I'm so confused with multidimensional arrays. May I please ask a couple questions? 1.) In the json array below, How do I use PHP to echo, for example, the price offered by Susan? I tried things like echo $result["data"][0]["Susan"] to work, but it won't work. 2.) Near the top of the array it shows the lowest price is $25.56. How do I get PHP to echo that? Again, I tried echo $result[LowestPrice] but that doesn't work. 3.) The array below is really big. What code do I use to create a smaller array of just [Name] and [OfferingPrice] ?? If I can do that, then I can do the PHP thing
  14. Php Gurus, Is there a way how you could have more than one delimiter in the following functions ? explode implode Tutorials always shows one. But let us say, we need more than one. In that case, what would you do without coding separately one by one for each delimiter ? If regex then I'd like to see some code samples. Remember, a code sample would be appreciated by all present & future newbies. Explode Imagine I want to explode this: 'The "quick brown" fox jumps over the \'lazy dog\'.' To this: ' The "quick brown" fox jumps over the \'lazy
  15. When I send values to the foreach they are not recorded in the array. $x = $getProductID; $_SESSION['pColors'] = array(); if(isset($_POST['pColors'])) { foreach($_POST['pColors'] as $colorKey => $RColors) { $_SESSION['pColors'][$colorKey] = $RColors; } } var_dump($_SESSION['pColors']); Send date with AJAX: $('.addToCart').click(function(){ $.ajax({ url:""+realLink+"cart.php", method:"POST", data:{action:action,pColors:pColors},
  16. I have a php script which runs a sql query and writes it to a CSV, which works perfectly. However, I created a second modified version of the script because I want to write the same CSV, but with an additional row beneath each group of data for totals. Currently, the results are ordered by User Extension (CSRs and phone numbers). So for extension 7200 I want, let's say, all 10 of their calls and then another row to total the calls and the individual columns. I currently have the query returning an 'x' for indicators. So one user might have 10 calls and 4 'x's in the 'inbound' column. I wou
  17. I am creating a function to set a cookie of the last three viewed items and then display the items except the item I am on. The issue I am having is after the second product I view, it will show duplicate items. I outputted the query and there are no duplicates. I tried array_unique. function definerecentview() { global $wpdb; $myvaluee = $_GET['singleProduct']; add_action('init', 'definerecentview'); if ( empty($_COOKIE['recently_viewed'])) $viewed_products = array(); else $viewed_products = (array) explode( ',', $_COOKIE['recently_viewed']); if ( ! in_array($my
  18. I'm trying to build a tree to display product groups, but I can't achieve what I want. There is a hierarchy for the tree which I need to follow: 1H 1HS 1HSMP I want to list all the categories (1H) with its subcategories(1HS), and it's subcategories (1HSMP). This is the code I'm currently using: <ul> <?php //Here we fetch category $categories_list = array();
  19. I'm trying to create a code that moves a string array A B C D E around based on the amount specified entered into a field in a form and the direction which is also entered into the form. What I want to do is to make the $newarray equal $array when the page is refreshed and the submit button is hit again. That way A B C D E when moved LEFT by 1 will be B C D E A and then if RIGHT and 2 is entered, you will see E A B C D. I've been struggling to get session working and just ended up more lost. Here is the code I got so far. I would greatly appreciate any help with this. <html> &l
  20. Hi, The following code seems to be echoing the array numbers. I actually need to echo the array value and not the numbers. Echo: Values of the matched banned words. Echo: Values of the non-matched banned words. So, how to correct the following code which shows results like this: Script 5a - No Match: (0) Script 5a - Banned: array(1) Script 5a - Banned: array(2) Script 5a - Banned: array(3) Script 5a - Banned: array(4) NOTE: "0" is being shown as "no match". But how come when "0" exists both in the content and banned words array ? <?php //script 5d: https://stackoverflow.com
  21. Hi How can I custom sort this array into any order I specify by say the object key - name like this P2,P1,P3 or by id sku991,sku838,sku123, Here is a PHP var dump array(3) { [0]=> object(stdClass)#212 (2) { ["id"]=> string(36) "sku838" ["name"]=> string(61) "P1" } [1]=> object(stdClass)#235 (2) { ["id"]=> string(36) "sku991" ["name"]=> string(61) "P2" } [2]=> object(stdClass)#240(2) { ["id"]=> string(36) "sku123" ["name"]=> string(61) "P3" } } Thankyou
  22. Hello everyone, I'm getting there, but not perfect. Still learning to do write the script in PHP. Anyway, I am trying to get set up the flexible array and values in html and SQL. I am trying to make different name, cannot same name in loop. For example, in PHP, to get data value from $_POST from name from input in form area in html, so I can't figure how to get like array. In loop, look like: using for or foreach loop, I need to have <input type="text" name="label$j"> in different number, like to have loop name = label1, label2, label3... But I found php print the loop same - la
  23. This is my array. It has stored images data. [other-image] => Array ( [img] => Array ( [0] => 1526973657.jpg [1] => 1526973661.jpg [2] => 1526973665.jpg ) [path] => Array ( [0] => ../post-upload/1/ [1] => ../post-upload/1/ [2] => ../post-upload/1/ ) [type] => Array ( [0] => 1 [1] => 1 [2] => 1 ) [thumb] => Array ( [0] => thumb_1526973661.jpg
  24. I'm trying to make a function that checks if there are enough seats available for visitors. If there's enough room for the visitors, return an array with suggested seats, else return null. Method: I'm making a gap, this gap will be increased by 1 everytime there is a available seat. At the end of my function, I compare if the $visitors fit in the $gap, if they don't return null and if they do, return the array. The problem: My function returns an array even though there's not enough room. My question: How do I let my function return null if there are not enough seats? This is my cod
  25. Hi all, I would like to ask you if somebody could have a better idea to build this function. The current one is working, but I feel this built a bit in an amateur manner. Feel free to add your ideas so we can learn more about PHP and how to deal with arrays. I have an array: $arrayVideoSpecs = Array( Array( 'aspect' => '4:3', 'density' => '442368', 'resolution' => '768x576' ), Array( 'aspect' => '4:3', 'density' => '307200', 'resolution' => '640x480' ), Array( 'aspect' => '16
  • 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.