Search Results

Search found 42698 results on 1708 pages for 'php in array'.

Page 9/1708 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • randomize array using php

    - by Suneth Kalhara
    I need to rendomise the order of follow array using PHP, i tried to use array shuffle and array_random but no luck, can anyone help me please Array ( [0] => Array ( [value] => 4 [label] => GasGas ) [1] => Array ( [value] => 3 [label] => Airoh Helmets ) [2] => Array ( [value] => 12 [label] => XCiting Trials Wear ) [3] => Array ( [value] => 11 [label] => Hebo Trials ) [4] => Array ( [value] => 10 [label] => Jitsie Products ) [5] => Array ( [value] => 9 [label] => Diadora Boots ) [6] => Array ( [value] => 8 [label] => S3 Performance ) [7] => Array ( [value] => 7 [label] => Scorpa ) [8] => Array ( [value] => 6 [label] => Inspired ) [9] => Array ( [value] => 5 [label] => Oset ) )

    Read the article

  • Can't concatenate 2 arrays in PHP

    - by alex
    I've recently learned how to join 2 arrays using the + operator in PHP. But consider this code... $array = array('Item 1'); $array += array('Item 2'); var_dump($array); Output is array(1) { [0]= string(6) "Item 1" } Why does this not work? Skipping the shorthand and using $array = $array + array('Item 2') does not work either. Does it have something to do with the keys?

    Read the article

  • how can i change include path in php.ini file

    - by Duleep
    my php.ini(C:\php) file include path ; Windows: "\path1;\path2" include_path = ".;C:\php\extras;C:\php\extras\doctrine-dbal" but phpinfo() look as include_path =.;C:\php\pear how can i change include path as include_path = ".;C:\php\extras;C:\php\extras\doctrine-dbal" i'm sure there ara no more php.ini file and my apache web server were restart when i view include path using <?php phpinfo(); ?>

    Read the article

  • How to combine two arrays of same length to one array with two fields (not append/merge)

    - by Raj
    Say, I have an array with months $months = array('Jan', 'Feb', 'Mar'...'Dec'); And another, with days (say, for year 2010) $mdays = array(31, 28, 31...31); I want to merge/combine these two arrays, into an array like this: $monthdetails[0] = ('month' => 'Jan', 'days' => 31) $monthdetails[1] = ('month' => 'Feb', 'days' => 28) ... $monthdetails[11] = ('month' => 'Dec', 'days' => 31) I can loop through both the arrays and fill the $monthdetails. I want to know whether there are any functions/easier way for achieving the same result. Thanks! Raj

    Read the article

  • Settings on php.ini ignored

    - by bfavaretto
    I can't get my server to obey the settings from php.ini (I'm trying to change memory_limit and upload_max_filesize). As far as I can tell, I'm editing the correct file. phpinfo() gives: Loaded Configuration File /etc/php.ini The file permission is 644. There are also some extra .ini files on /etc/php.d, but none include any of the keys I'm trying to change. No matter what I do, phpinfo reports the default values on both "Local" and "Master" columns. I also scanned my Apache config files, but found nothing related to PHP (besides loading the PHP module). The only way I was able to change those settings was by adding some php_value lines to my .htaccess. Is there something obvious I'm missing? This is a virtual server, and I can perform root commands with sudo. I'm running Apache 2.1.3 and PHP 5.3.3. System info (from uname -a) is: Linux sesctbapp01 2.6.18-308.1.1.el5 #1 SMP Wed Mar 7 04:16:51 EST 2012 x86_64

    Read the article

  • PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/apc.so'

    - by user3207586
    I have updated my php from 5.3.3 to 5.4.31. I have a Debian 6 Squeeze. PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/apc.so' - /usr/lib/php5/20100525/apc.so: cannot open shared object file: No such file or directory in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/suhosin.so' - /usr/lib/php5/20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0 During the installation, the system ask me if I want to keep the actual php.ini or put the new one. I said to keep the actual one. Now, I have this 2 errors when I restart Apache.. What should I do to solve them?

    Read the article

  • PHP-FPM for nginx on debian

    - by Jelko
    What is the preferred/recommended way of installing php-fpm on debian for use with nginx? I read about a "php5-fpm" package everywhere, but it's not available in the official debian repos any more. The PHP-FPM website (http://php-fpm.org/download/) says that fpm is now included with the php core. Is it enough to install "php5-common" then? Where are the config files, though? Other people recommend to install the current version of php and php-fpm from dotdeb.org. The versions provided there are generally more up to date. But is it secure? Is this a good repo to use in a production environment? I would appreciate any advice.

    Read the article

  • how to sort a multidemensional array by an inner key

    - by Derek Vance
    i have this enormous array that i am pulling from an API for BattleField Bad Company 2, and the soldier stats can be pulled as a multi dimensional array with an inner array for each soldier, however the API sormats it sorting the soldiers by name alphabetically, i want to sort them by rank (which is just another key within that soldiers array). ive been trying to figure this out for days, anyone have any ideas? (ie sort the array by $arr[players][][rank] here is a bit of the array Array ( [players] = Array ( [0] = Array ( [name] = bigjay517 [rank] = 29 [rank_name] = SECOND LIEUTENANT II [veteran] = 0 [score] = 979440 [level] = 169 [kills] = 4134 [deaths] = 3813 [time] = 292457.42 [elo] = 319.297 [form] = 1 [date_lastupdate] = 2010-03-30T14:06:20+02:00 [count_updates] = 13 [general] = Array ( [accuracy] = 0.332 [dogr] = 86 [dogt] = 166 [elo0] = 309.104 [elo1] = 230.849 [games] = 384 [goldedition] = 0 [losses] = 161 [sc_assault] = 146333 [sc_award] = 567190 [sc_bonus] = 35305 [sc_demo] = 96961 [sc_general] = 264700 [sc_objective] = 54740 [sc_recon] = 54202 [sc_squad] = 53210 [sc_support] = 70194 [sc_team] = 21215 [sc_vehicle] = 44560 [slevel] = 0 [spm] = 0 [spm0] = 0 [spm1] = 0 [srank] = 0 [sveteran] = 0 [teamkills] = 67 [udogt] = 0 [wins] = 223 )

    Read the article

  • foreach loop corrupting my array?

    - by WmasterJ
    Explanation I have a multidimensional array that is iterated over to created a categorized view of people with different research interests. The main array look something like this: Array ( ... ['Cell Biology'] => Array(4 elements) ['Molecular'] => Array(6 elements) ['Biology Education'] => Array(14 elements) ['Plant Biology'] => Array(19 elements) <--- Last element in array ) I know that the entire array is intact and correctly structured. The only information that is inside these array is an user id, like so: Array ('Plant Biology') 19 elements ( [0] => 737 [1] => 742 [2] => 748 ... ) My problem is that after i run the main array through a foreach loop the last 'sub-array' gets messed up. By messed up I mean that what you see about instead look like: String (13 characters) 'Plant Biology' This is without doing at all anything inside the loop with to the array that gets corrupted. Any tips to what it might be? PHP Code // ---> Array is OK here echo "<h2>Research divided</h2>"; // Loop areas and list them in 2 columns foreach($research['areas'] as $area => $areaArray) { // ---> Here it is already corrupted $count = count($areaArray); if($count > 0) { echo "<h3>$area</h3><hr/>"; echo "<table class='area_list'><tr>"; // Loop users within areas, divided up in 2 columns for($i=0 ; $i<$count ; $i++) { $uid = $areaArray[$i]; echo "<li>$uid</li>"; } echo "</tr></table>"; } }

    Read the article

  • PHP : flatten array - fastest way?

    - by Industrial
    Is there any fast way to flatten an array and select subkeys ('key'&'value' in this case) without running a foreach loop, or is the foreach always the fastest way? Array ( [0] => Array ( [key] => string [value] => a simple string [cas] => 0 ) [1] => Array ( [key] => int [value] => 99 [cas] => 0 ) [2] => Array ( [key] => array [value] => Array ( [0] => 11 [1] => 12 ) [cas] => 0 ) ) To: Array ( [int] => 99 [string] => a simple string [array] => Array ( [0] => 11 [1] => 12 ) )

    Read the article

  • Create shortcut for PHP

    - by Daniel
    I have XAMPP installed and my PHP is: /opt/lampp/bin/php-5.3.8 Every time I need to execute a PHP file I need to do this: /opt/lampp/bin/php-5.3.8 testando.php Is there another way to execute it besides using symbolic link? I did this on /etc/init.d/: sudo ln -s /opt/lampp/bin/php-5.3.8 php Why when I need to run PHP I have to do this ./php instead of just php? And is there a way to do this without the ./? Like it was installed via apt-get?

    Read the article

  • Combining array values in multilevel array

    - by James Huckabone
    I have an array like so: array( 'a'=>array( 'a'=>3, 'f'=>5, 'sdf'=>0), 't'=>array( 'a'=>1, 'f'=>2, 'sdf'=>5), 'pps'=>array( 'a'=>1, 'f'=>2, 'sdf'=>3) ); Notice how the sub-arrays are the same for each top-level array. If I wanted to, what's the easiest way to combine the sub-arrays so that I'm left with a one-dimensional array like: array( 'a'=>5, 'f'=>9, 'sdf'=>8 );

    Read the article

  • Apache VirtualHosts define php.ini but extend main php.ini

    - by Hosh Sadiq
    I have a main php.ini file and am wondering if it is possible to specify a custom php.ini for a virtualhost, but this php.ini would extend the main php.ini file, so that only the specified settings are overridden and everything else is taken the main php.ini. For example: I have my main php.ini file in /etc/php5/php.ini, containing all the defaults. Let's say this has everything as default so e.g. allow_url_fopen = On allow_url_include = Off Then I have my virtualhost located at /home/user/php.ini and this contains the following: allow_url_fopen = Off This php would run with first the php.ini in /etc/php5/php.ini then the settings that are in /home/user/php.ini resulting in a configuration where both allow_url_fopen and allow_url_include are set to Off. Edit: Also, if /home/user/php.ini does not exist, it would default back to /etc/php5/php.ini

    Read the article

  • Centos 6.5 -- backported upgrades/php.ini directives included in php 5.3.3

    - by Decave
    PHP 5.3.3 is the latest version of PHP available with the official CentOS 6.5 repos. As most of you know, calling it version '5.3.3' is slightly deceptive because critical bug fixes are actually back ported into version 5.3.3, so in effect 'version 5.3.3' does get upgraded now and then. My question is: aside from manually toggling directives in php.ini, how can you tell which new directives, that were implemented in, and officially supported by, later versions of PHP, are also available in CentOS 6.5's backported PHP 5.3.3? For example, max_input_vars (http://php.net/manual/en/info.configuration.php#ini.max-input-vars) has been available since PHP 5.3.9. IS there an easy way to tell whether CentOS included this in a backported upgrade to 5.3.3? Thanks!

    Read the article

  • PHP enable sqlite phpinfo states --without-sqlite

    - by Jahmic
    I've seen similar questions but none that address my situation adequately. I'm running Apache and PHP 5.3.6 on a amazon cloud server. phpinfo keeps stating that sqlite is disabled. At least that what it seems from the configure line: './configure' ... '--without-sqlite' In other parts of phpinfo() output: PDO PDO drivers mysql, sqlite PDO Driver for SQLite 3.x enabled SQLite Library 3.6.20 sqlite3 SQLite3 support enabled SQLite3 module version 0.7-dev SQLite Library 3.6.20 Directive Local Value Master Value sqlite3.extension_dir no value no value and at least one the following PHP commands fail: if (!extension_loaded('SQLite') OR !function_exists('sqlite_open')) Yum install states that both sqlite and pdo-lite are already installed. I've tried to enable sqlite by editing my local php.ini by adding: ; Enable sqlite3 extension module extension=sqlite3.so I've checked the main php.ini (/etc/php.ini) and there is nothing specific about disabling it. In fact, there is a sub-conig file loaded in php.d that also specifies this extension as well as another for the pdo-sqlite I'm running of things to look for or try. Any suggestions. How do I find where the PHP configure is stated? Thanks

    Read the article

  • FastCGI Error when installing PHP on IIS7.5

    - by ytoledano
    I'm trying to install MediaWiki on a Win2008r2 server, but can't manage to install PHP. Here's what I did: Grabbed a Zip archive of PHP and unzipped it into C:\PHP. Created two subdirs: c:\PHP\sessiondata and c:\PHP\uploadtemp. Granted modify rights to the IUSR account for the subdirs. Copied php.ini-production as php.ini Edited php.ini and made the following changes: fastcgi.impersonate = 1 cgi.fix_pathinfo = 1 cgi.force_redirect = 0 open_basedir = "c:\inetpub\wwwroot;c:\PHP\uploadtemp;C:\PHP\sessiondata" extension = php_mysql.dll extension_dir = "./ext" upload_tmp_dir = C:\PHP\uploadtemp session.save_path = C:\php\sessiondata Install Web server role, selected CGI and HTTP Redirection options. In the Handler Mappings: Added Module Mapping. Entered the following values: Path = *.php, Module = FastCgiModule, Executable = c:\php\php-cgi.exe, Name = PHP via FastCGI. Created a test page into wwwroot directory: phpinfo.php and set the contents like this: < ?php phpinfo(); ? Browsed to http://localhost/phpinfo.php But then I get: HTTP Error 500.0 - Internal Server Error An unknown FastCGI error occured Detailed Error Information Module: FastCgiModule Notification: ExecuteRequestHandler Handler: PHP via FastCGI Error Code: 0x800736b1 Requested URL: http://localhost:80/phpinfo.php Physical Path: C:\inetpub\wwwroot\phpinfo.php Logon Method: Anonymous Logon User: Anonymous Does anyone know what I'm doing wrong here? Thanks.

    Read the article

  • nginx: php-fastcgi running but php files not executing

    - by Daniel
    I have recently set up a nginx server with PHP running as FastCGI process. The server is running with HTML files however PHP files are downloading instead of displaying and PHP code is not processed. This is what I have in nginx.conf: server { listen 80; server_name pubserver; location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name; include fastcgi_params; } } The command netstat -tulpn | grep :9000 displays the following which indicates php-fastcgi is running and listening on port 9000: tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2663/php-cgi If it's if any importance my server is running on CentOS 6 and I installed nginx and PHP using the repositories from The Fedora Project.

    Read the article

  • Apache 2.2/PHP is not loading the correct php.ini

    - by Jesper
    I have been struggling with this for days. I have a windows server 2008 where I have installed Apache 2.2, PHP and MySql. I kept getting the error that mysql_connect was an unknown function, so I followed all guides I could find but with no result. I have now noticed that phpinfo says that php.ini dir is C:\Windows. This is strange since I've written this in httpd.conf: PHPIniDir 'c:\PHP\' LoadModule php5_module "c:/PHP/php5apache2_2.dll" AddHandler application/x-httpd-php .php How do I get apache and php to read my php.ini and thereby include mysql?

    Read the article

  • PHP 5.2 Function needed for GENERIC sorting FOLLOWUP

    - by donbriggs
    OK, you guys gave me a great solution for sorting a recordset array last Friday. (http://stackoverflow.com/questions/2884325/php-5-2-function-needed-for-generic-sorting-of-a-recordset-array) But now when I implement it, I end up with an extra element in the recordset array. I won't wast space reposting the same info, as the link is above. But the bottom line is that when I sort an array of 5 records, the resulting array has 6 records. The last element in the array is not a record array, but rather just a element containing an integer value of 1. I presume that it is somehow getting the output value of the "strnatcasecmp" function, but I have no idea how it is happening. Here is the function that you fine folks provided last week: function getSortCommand($field, $sortfunc) { return create_function('$var1, $var2', 'return '.$sortfunc.'($var1["'.$field.'"], $var2["' .$field .'"]);'); } And here is the line I am calling to sort the array: $trek[] = usort($trek, getSortCommand('name', 'strnatcasecmp')); This produces the following output, with an extra element tacked on to the end. Array ( [0] = Array ( [name] = Kirk [shirt] = Gold [assign] = Bridge ) [1] => Array ( [name] => McCoy [shirt] => Blue [assign] => Sick Bay ) [2] => Array ( [name] => Scotty [shirt] => Red [assign] => Engineering ) [3] => Array ( [name] => Spock [shirt] => Blue [assign] => Bridge ) [4] => Array ( [name] => Uhura [shirt] => Red [assign] => Bridge ) [5] => 1 )

    Read the article

  • PHP-FPM conf location option when compiling php

    - by Danack
    I'm compiling PHP from source. I would like to set the location that PHP-FPM looks for it's config file. Apparently this option should be set via the configure option: --with-fpm-conf=/etc/php/php-fpm.conf According to http://php-fpm.org/wiki/Configuration_File However using this option on PHP5.5.0 gives the error configure: WARNING: unrecognized options: --with-fpm-conf How do I set where PHP-FPM should look for it's conf file when compiling from source?

    Read the article

  • PHP Function needed for GENERIC sorting of a recordset array

    - by donbriggs
    Somebody must have come up with a solution for this by now. I wrote a PHP class to display a recordset as an HTML table/datagrid, and I wish to expand it so that we can sort the datagrid by whichever column the user selects. In the below example data, we may need to sort the recordset array by Name, Shirt, Assign, or Age fields. I will take care of the display part, I just need help with sorting the data array. As usual, I query a database to get a result, iterate throught he result, and put the records into an assciateiave array. So, we end up with an array of arrays. (See below.) I need to be able to sort by any column in the dataset. However, I will not know the column names at design time, nor will I know if the colums will be string or numeric values. I have seen a ton of solutions to this, but I have not seen a GOOD and GENERIC solution Can somebody please suggest a way that I can sort the recordset array that is GENERIC, and will work on any recordset? Again, I will not know the fields names or datatypes at design time. The array presented below is ONLY an example. Array ( [0] = Array ( [name] = Kirk [shrit] = Gold [assign] = Bridge ) [1] => Array ( [name] => Spock [shrit] => Blue [assign] => Bridge ) [2] => Array ( [name] => Uhura [shrit] => Red [assign] => Bridge ) [3] => Array ( [name] => Scotty [shrit] => Red [assign] => Engineering ) [4] => Array ( [name] => McCoy [shrit] => Blue [assign] => Sick Bay ) )

    Read the article

  • nginx + php fpm -> 404 php pages - file not found

    - by Mahesh
    *2037 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream server { listen 80; ## listen for ipv4; this line is default and implied #listen [::]:80 default ipv6only=on; ## listen for ipv6 server_name .site.com; root /var/www/site; error_page 404 /404.php; access_log /var/log/nginx/site.access.log; index index.html index.php; if ($http_host != "www.site.com") { rewrite ^ http://www.site.com$request_uri permanent; } location ~* \.php$ { fastcgi_index index.php; fastcgi_pass 127.0.0.1:9000; #fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_buffer_size 128k; fastcgi_buffers 256 4k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; fastcgi_read_timeout 240; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } location ~ /\. { access_log off; log_not_found off; deny all; } location ~ /(libraries|setup/frames|setup/libs) { deny all; return 404; } location ~ ^/uploads/(\d+)/(\d+)/(\d+)/(\d+)/(.*)$ { alias /var/www/site/images/missing.gif; #i need to modify this to show only missing files. right now it is showing missing for all the files. } location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { access_log off; expires 20d; } location /user_uploads/ { location ~ .*\.(php)?$ { deny all; } } location ~ /\.ht { deny all; } } php-fpm config is default and is not touched. The problem is little strange for me. Error pages are showing File not found only if they are .php files. Other error files are clearly calling the 404.php file site.com/test = calls 404.php site.com/test.php = File not found. I am searching and making changes. but it hasn't solved the problem.

    Read the article

  • Adding an Array inside an array in a PHP function

    - by bateman_ap
    I have created a function in PHP that calls a webservice and parses through the result, assinging values to variables and returning them all as an Array. This all works perfectly, however I have come across a need to have an "array within my array" I am assigning values as below: $productName = $product->Name; $productID = $product->ID; $productArray = array( 'productName' => "$productName", 'productID' => "$productID" ); return $productArray; However I now have a piece of data that comes back with multiple results so I need to have a additional array to store these, I am getting the values from the returned XML using a foreach loop, however I want to be able to add them to the array with a name so I can reference them in the returned data, this is where I have a problem... $bestForLists = $product->BestFors; foreach( $bestForLists as $bestForList ) { $productBestFors = $bestForList->BestFor; foreach( $productBestFors as $productBestFor ) { $productBestForName = $productBestFor->Name; $productBestForID = $productBestFor->ID; } } I tried creating an array for these using the below code: $bestForArray[] = (array( "productBestForID" => "$productBestForID", "productBestForName" => "$productBestForName" )); And then at the end merging these together: $productArray= array_merge($productArray,$bestForArray); If I print out the returned value I get: Array ( [productName] => Test Product [productID] => 14128 [0] => Array ( [productBestForID] => 56647 [productBestForName] => Lighting ) [1] => Array ( [productBestForID] => 56648 [productBestForName] => Sound ) ) I would like to give the internal Array a name so I can reference it in my code, or is there a better way of doing this, at the moment I am using the following in my PHP page to get values: $productName = $functionReturnedValues['productName']; I would like to use the following to access the array I could then loop through: $bestForArray = $functionReturnedValues['bestForArray']; Hope someone can help

    Read the article

  • How to sort a multidimensional array by a certain key?

    - by Eelke
    This should be really simple, but what is the way to go on this. I want to sort an multidimensional array by a key, like this: Array ( [0] => Array ( [iid] => 1 [invitee] => 174 [nid] => 324343 [showtime] => 2010-05-09 15:15:00 [location] => 13 [status] => 1 [created] => 2010-05-09 15:05:00 [updated] => 2010-05-09 16:24:00 ) [1] => Array ( [iid] => 1 [invitee] => 220 [nid] => 21232 [showtime] => 2010-05-09 15:15:00 [location] => 12 [status] => 0 [created] => 2010-05-10 18:11:00 [updated] => 2010-05-10 18:11:00 )) Say i want to sort this by [status], how would I achieve this? Thanks in advance!

    Read the article

  • All possibilities in 2d array

    - by valli-R
    I have this array: $array = array ( array('1', '2', '3'), array('!', '@'), array('a', 'b', 'c', 'd'), ); And I want to know all character combination of sub arrays.. for example : 1!a 1!b 1!c 1!d 1@a 1@b 1@c 1@d 2!a 2!b 2!c 2!d 2@a 2@b ... Currently I am having this code : for($i = 0; $i < count($array[0]); $i++) { for($j = 0; $j < count($array[1]); $j++) { for($k = 0; $k < count($array[2]); $k++) { echo $array[0][$i].$array[1][$j].$array[2][$k].'<br/>'; } } } It works, but I think it is ugly, and when I am adding more arrays, I have to add more for. I am pretty sure there is a way to do this recursively, but I don't know how to start/how to do it. A little help could be nice! Thanks you!

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >