Category Archives: arrays

Apache Phoenix Array Modification

I am using Phoenix for my project and I am stuck with Array types. My query is, suppose I have an array column in my table, I am inserting the data in that array, and after some time, weeks, months I will need to update the array, basically append/remove the data to/from it, basically modify the array but I am unable to find the solution for it. Could you help me with this?

I found this in the Limitations of array on --> Partial update of an array is currently not possible. Instead, the array may be manipulated on the client-side and then upserted back in its entirety.

Is there any work around for this?

Phoenix array type:

SELECT … FROM … WHERE … = … returns empty array after fetchAll() [duplicate]

This question already has an answer here:

I am trying to fetchAll() an array for rows in my database that are from a certain category.

require 'database.php'; 
$class = $_GET["class"];
$classes = $conn -> prepare("SELECT * FROM items WHERE class = $class");
$classes -> execute();
$all_items_from_class = $classes -> fetchAll();

On the previous page I want the user to click on a category and lead him to a page where it loads all items of that specific category, the URL will show something like and display all items from that specific class. After trying different foreach loops and not getting any results, I checked with a var_dump() to see what is wrong with the array $all_times_from_class and to my surprise it returns a completely empty array.

When I remove the WHERE from SELECT it returns the entire array of all items, but for some reason it does not with WHERE. I used $_GET in the same way in another .php file and it works fine there, but not when I try to $_GET the class. Why does it not return an array for that specific category? Does it not recognise what class to get from the URL, does it not work for VARCHARs in the database? I'm at a loss at the moment. The only fix I know would be to foreach() the entire database and run every row through an if.

Hide files in array and show other content

I have my delete function after file is deleted it will print all deleted file in array like this bellow

Array (

[0] => [File]: C:\xampp\htdocs\public_html\cjl\jquery-sandbox\zuuttt\default.php

[1] => [File]: C:\xampp\htdocs\public_html\cjl\jquery-sandbox\zuuttt.htaccess

[2] => [Directory]: C:\xampp\htdocs\public_html\cjl\jquery-sandbox\zuuttt

[3] => [File]: C:\xampp\htdocs\public_html\cjl\jquery-sandbox\zuuttt\page.html


The main directory is jquery-sandbox

And sub directory which was deleted and it file content is zuuttt

Now my problem is that i have two files inside zuuttt which i don't want it to show it deleted array list i want it to be hidden i tired to do this but it still show the files.

//The delete is working fine and below here is from my class
$result = $rmjails->remove($deletethis);

//This is what i tried to hide it with
$hide = array('.htaccess','default.php');
$filtered_array = array_filter($result, function ($element) use ($hide) { return ($element != $hide); } );

//This is default one i was using


How can i hide that two files .htaccess and default.php?

2 additional questions

My question yesterday was not answers till now please i need a help about that

Having multiple htaccess in a root directory

How can i print out the deleted files and directories without showing it in array Array ([0] => [File]: C:\xampp\htdocs\public_html\cjl\jquery-sandbox\zuuttt\default.php) so it will look like this [File]: C:\xampp\htdocs\public_html\cjl\jquery-sandbox\zuuttt\default.php

Thank you

How to convert PHP associative array to Java NameValuePair for HttpPost

I have a piece of php code that needs to be sent via HttpPost.

$data = array(
'html' => '<h1 style="color:blue">Test Email</h1>
<p>Dear {name} {lname}</p>
<p>your email is {email} and phone number is {phone}</p>',
'subject' => 'email test',
'headers' => array(
'Reply-To' => '[email protected]'
'from' =>   array(
'email' => '[email protected]',
'name' => 'no reply'
'to' => array(
'email' => '[email protected]',
'name' => 'recipient_one',
'type' => 'to',
'vars' => array(
'name'  => 'recipient',
'lname' => 'one',
'email' => '[email protected]',
'phone' => '8888888888',

So far I have tried the following neglecting any headers such as Reply-To (it is optional). The vars array above is a list of replaceable variables used in the emailer content for each user which is not very useful after converting it to NameValuePair, but have kept it because it is required according to the specification. Please neglect the number of parenthesis at the end...I have correctly used it in my code.

Edit: get a response saying "No From Address" when I append "data" to each of the pairs like below.

List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair(
            "<h1 style='color:blue'>Test Email</h1><p>Dear Example</p><p>your email is [email protected] and phone number is 9xxxxxxxxx</p>"));
    params.add(new BasicNameValuePair("data[subject]", "Test Email"));
    params.add(new BasicNameValuePair("data[from][email]", "[email protected]"));
    params.add(new BasicNameValuePair("data[from][name]", "Someone"));
    params.add(new BasicNameValuePair("data[to][0][email]",
            "[email protected]"));
    params.add(new BasicNameValuePair("data[to][0][name]", "Someone"));
    params.add(new BasicNameValuePair("data[to][0][type]", "to"));
    params.add(new BasicNameValuePair("data[to][0][vars][name]", "someone"));
    params.add(new BasicNameValuePair("data[to][0][vars][lname]", "someone"));
    params.add(new BasicNameValuePair("data[to][0][vars][email]",
            "[email protected]"));
    params.add(new BasicNameValuePair("data[to][0][vars][phone]", "9xxxxxxxxx"));

Any corrections to be made in the java code?

converting object to array then adding element to end of array then shuffle

I figured it was time to ask because i have been working on this for over an hour.

I need to take an object and convert it to array - done I need to add a new element to the end of the array as [9] => value - ISSUE :( I need to shuffle the array - done

Everything i try it always comes out like this

here is $wlist as the original class object

 CAPTCHA_CLASS_Wordlist Object
[jsObjectList] => Array
        [0] => providers
        [1] => chemical
        [2] => family
        [3] => supported
        [4] => urban
        [5] => produced
        [6] => continued
        [7] => stream
        [8] => administrative


which after conversion is this

[0] => Array
        [0] => claim
        [1] => continued
        [2] => limit
        [3] => platform
        [4] => websites
        [5] => efforts
        [6] => dollars
        [7] => saint
        [8] => family

[1] => water

it has to be [9] => value

i have even tried $arrayname[9] = $value and $arrayname[0][9] without success.. Even if i recreate the array inside a foreach i still have the same problem not being able to add the extra element at the end as key [9]

here is my code

      //convert object to array
     $convert = (array)$wlist;

     //now add the answer to it
     array_push($convert, $questanswer);

     //now shuffle

     $final = shuffle($convert);

$questanswer is just a text word like - house

thanks :)

Update: here is what it looks like after stdClass

         //convert object to array
     $convert = (array)$wlist;

     //new stdClass and load it
     $nc = new stdClass;
     $nc->questanswer = $questanswer;

     //now add the answer to it
     array_push($convert[0], $nc);

     $finaloptions = shuffle($convert);

  [0] => stdClass Object
        [questanswer] => hexagon

[1] => Array
        [0] => labor
        [1] => designated
        [2] => shops
        [3] => load
        [4] => fresh
        [5] => mass
        [6] => patch
        [7] => foot
        [8] => congress


Post array coming with only 500 records as output on server

I have more than 3000 records and i want to pass it in post array but it will giving me only 500 array as output on server. My project is on php base.

I have tried to change below but didnt succeed.

1) Using .htaccess file.

php_value max_input_vars 10000


<IfModule mod_php5.c>
php_value max_input_vars 5000

But in both i got

500 internal server error.

2) Using ini_set() in my index.php file.


This will also not worked as suggest that

'max_input_vars' not changable because of PHP_INI_PERDIR.

3) Using php.ini file.

max_input_vars = 10000

I can do this on my local and its work but on server/cpanel i want able to find this file.

Suggest me what should i want to do to exceed array size also suggest if any other way to achieve it. Also if anyone tell me how to change it using SSL command.

Thank you in advance.

$_POST not submitting the form, array prints as array()

Below is the form I'm using to submit a new wheel into a DB on my local XAMPP server, problem is the post method doesn't work, I had problems with a modal which was sorted by using $_GET instead. I've changed a few php.ini settings but have changed them back was, max_upload and another one, I've read about them in other questions but they don't seem to solve the issue.

When I use the submit form below the array printed is just Array(), doesn't even have a single value, this should prompt my error check to print an error at the least.

<!-- wheels form -->
<div class="text-center">
    <form class="form-inline" action="wheels.php" method="post">
        <div class="form-group">
            <label for="wheelName">Add a new wheel:</label>
            <input name="wheelName" type="text" id="wheelName" class="form-control" value="<?=((isset($_POST['wheelName']))?$_POST['wheelName']:''); ?> "><!-- shorthand if/else-->
            <label for="code">Stockcode</label>
            <input name="code" type="text" id="code" class="form-control" value="<?=((isset($_POST['code']))?$_POST['code']:''); ?> "><!-- shorthand if/else-->
            <input type="submit" name="add_submit" value="add wheel" class="btn btn-success">

Standard php sql input and checks, the information is being pulled correctly as I have it displaying in a table further on my page.But the $_POST variable appears to be completely empty, has someone had this problem and managed to sort it? I'm assuming its to do with my php setup or HTaccess as someone else had an issue with.

require_once '../core/init.php';
include 'includes/header.php';
include 'includes/navigation.php';

// Get wheels from DB
$sql = "SELECT * FROM wheels ORDER BY part_no";
$result = $db->query($sql);
$errors = array();

// edit wheel
if(isset($_GET['edit']) && !empty(['edit'])) {
    $edit_id = (int)$_GET['edit'];
    $edit_id = sanitize('edit_id');
    //$sql2 = "SELECT * FROM wheels WHERE recid = '$edit_id'";
    //$edit_result = $db->query($sql2);
    //$eWheel = mysqli_fetch_assoc($edit_result);

// Delete wheel
if(isset($_GET['delete']) && !empty(['delete'])) {
    $delete_id = (int)$_GET['delete'];
    $delete_id = sanitize($delete_id);
    //$sql = "DELETE FROM wheels WHERE recid = '$delete_id'";
    //header('Location: wheels.php');

// If add wheel form submitted
if(isset($_POST['add_submit'])) {
    $wheel = sanitize($_POST['wheelName']);
    $stockCode = sanitize($_POST['stockCode']);

    // check if wheel is blank
    if($_POST['wheelName'] == '') {
        $errors[] .= 'Must enter wheel';

    // if wheel exists in db
    $sql = "SELECT * FROM wheels WHERE stockcode = '$stockCode'";
    $result = $db->query($sql);
    $count = mysqli_num_rows($result);
    if($count > 0) {
        $errors[] .= 'that wheel already exists.';

    // display errors
    if(!empty($errors)) {
        echo displayErrors($errors);
    } else {
        //Add wheels to DB // incomplete unsure if feature needed at this stage.
        // $sql = "INSERT INTO wheels (wheelName, stockCode, ID ETC ETC VALUES Etc ETC
        // $db->query($sql);
        // header ('location : wheels.php ');


echo file_get_contents("php://input");

::1 - - [23/Apr/2016:14:12:32 +1200] "GET / HTTP/1.1" 302 - "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

::1 - - [23/Apr/2016:14:12:32 +1200] "GET /dashboard/ HTTP/1.1" 200 6904 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

::1 - - [23/Apr/2016:14:12:32 +1200] "GET /dashboard/stylesheets/normalize.css HTTP/1.1" 200 6876 "http://localhost/dashboard/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

::1 - - [23/Apr/2016:14:12:32 +1200] "GET /dashboard/stylesheets/all.css HTTP/1.1" 200 481308 "http://localhost/dashboard/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

::1 - - [23/Apr/2016:14:12:32 +1200] "GET /dashboard/javascripts/modernizr.js HTTP/1.1" 200 51365 "http://localhost/dashboard/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

::1 - - [23/Apr/2016:14:12:33 +1200] "GET /dashboard/javascripts/all.js HTTP/1.1" 200 189003 "http://localhost/dashboard/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

::1 - - [23/Apr/2016:14:12:33 +1200] "GET /dashboard/images/xampp-logo.svg HTTP/1.1" 200 5427 "http://localhost/dashboard/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

::1 - - [23/Apr/2016:14:12:33 +1200] "GET /dashboard/images/bitnami-xampp.png HTTP/1.1" 200 22133 "http://localhost/dashboard/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

::1 - - [23/Apr/2016:14:12:33 +1200] "GET /dashboard/images/fastly-logo.png HTTP/1.1" 200 1770 "http://localhost/dashboard/" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

::1 - - [23/Apr/2016:14:12:33 +1200] "GET /dashboard/images/social-icons.png HTTP/1.1" 200 3361 "http://localhost/dashboard/stylesheets/all.css" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36"

enter image description here

Is it more efficient to fetch all DB rows at once in an array then parse or just parse each row?

When dealing with huge number of MySQL entries, is it more efficient to fetch them all at once in a PHP array or parse each row in a while fetch_assoc loop? I'm talking about hundreds of thousands of records that will grow into millions and, before I actually go about optimizing the DB, I'd like to know if there's a more efficient way to parse MySQL data with PHP. The parsing involves several validations and formatting before assigning to another array for inserting / updating another MySQL DB.

Hope this makes sense. Your views and suggestions are welcomed.

Can ArrayUtils be run from another computer without it installed

ArrayUtils: (org.apache.commons.lang3.ArrayUtils)

As I understand it, ArrayUtils can only be used in code if you have downloaded the Libraries locally. Does this mean that if I used ArrayUtils in my code that if someone else were to run it the code would not work? I ask because I've been working on a project of many small functions and using ArrayUtils would make it much easier, however I need someone to run the files after I send them to them.

NuSOAP returns empty array

I have the problem, that the NuSOAP server returns an empty array. I read and tried a lot of topics/things already but the result is always the same. I guess its only a minor thing you guys can solve within a minute.

I want to put an array of strings containing client information into another array that holds all servers:

       [Client1] => Array ([HostName] => 'TestHostName', [IP] => ''),
       [Client2] => Array ([HostName] => 'TestHostName', [IP] => ''),
       [Client3] => Array ([HostName] => 'TestHostName', [IP] => '')

The arrays will get filled from mysql data, but for testing purposes I created a static array with data. Here is what I have got so far:

require_once ('lib/nusoap.php');

$ServerName = 'server';
$ServiceName = 'CentralConfigService';
$ServiceURL = 'http://' . $ServerName . '/' . $ServiceName;

$Server = new soap_server();
$Server -> configureWSDL($ServiceName, $ServerName . '/' . $ServiceName);

function GetClientInfo($ClientName)
        $Clients = array();
        $ClientInfo = array(
                        'HostName' => 'testiname',
                        'IP' => 'testip',
                        'Type' => 'testtype',
                        'Config' => 'testconfig',
                        'Routines' => 'testroutines',
                        'Files' => 'testfiles',
                        'Access' => 'testaccess');
        $Clients[$ClientName] = $ClientInfo;
        return $Clients;

$Server -> wsdl -> addComplexType(
                'HostName' => array('name' => 'HostName', 'type' => 'xsd:string'),
                'IP' => array('name' => 'IP', 'type' => 'xsd:string'),
                'Type' => array('name' => 'Type', 'type' => 'xsd:string'),
                'Config' => array('name' => 'Config', 'type' => 'xsd:string'),
                'Routines' => array('name' => 'Routines', 'type' => 'xsd:string'),
                'Files' => array('name' => 'Files', 'type' => 'xsd:string'),
                'Access' => array('name' => 'Access', 'type' => 'xsd:string')

$Server -> wsdl -> addComplexType(
                array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:ClientInfo')

$Server -> register(
        array('HostName' => 'xsd:string'),
        array('return' => 'tns:Clients'),
        $ServiceURL . '#GetClientInfo',
        'Get config by type');

if ( !isset( $HTTP_RAW_POST_DATA ) ) $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );

@$Server -> service($HTTP_RAW_POST_DATA);


when I call the function "GetClientInfo", I always get an empty array:

    [0] => Array
        [0] => Array

        [1] => Array

        [2] => Array

        [3] => Array

        [4] => Array

        [5] => Array

        [6] => Array



The client calls the function:



    $wsdl = "http://server/server.php?wsdl";
    $client = new nusoap_client($wsdl, 'wsdl');

    $result = $client -> call('GetClientInfo', array('ClientName'=>'Client1'));


Sorry for the long post. I hope it contains all necessary information. Thanks a lot in advance!

Cheers, Daniel