Search Results

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

Page 31/1708 | < Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >

  • nginx clean url router/rewrites

    - by Janko
    im having difficulties with a relativity simple rewrite rules / router in nginx config. All I want to do is, if requested dir or file 'host/my/request/path[/[index.php]]' does not exist, rewrite to 'host/my/request/path.php' Current rewrite works for: host host/ host/my/request/path But wont work for: host/my/request/path/ Here is the rewrite part of the config: location = /(.*)/ { rewrite ^(.*)$ $1 permanent; } location / { try_files $uri/ $uri $uri.php; } Error log will report: Access forbidden by rule, request: "GET /my/request/path/ HTTP/1.0" Hm, is there a better way to solve this or get rid of the trailing slash? edit, rules more elaborative: host[/] > host/index.php host/index[/] > host/index.php host/my/path[/] > if /path/index.php exists: host/my/path/index.php else host/my/path.php

    Read the article

  • What is array portability?

    - by bobo
    From this page: http://www.doctrine-project.org/documentation/manual/1_2/en/working-with-models#dealing-with-relations:creating-related-records You can see that it says $obj['property']; is the recommended way of referring to an object's property in Doctrine for array portability purposes. I never heard about this term before and google did not come up with useful result. What is that?

    Read the article

  • Sorting a 2D array in obj-c?

    - by Debashis
    I have a 2D array as follows: [[@"string value", @"string value", NSInteger], [@"string value", @"string value", NSInteger], [@"string value", @"string value", NSInteger]] How would I sort the second dimension of arrays by the NSInteger?

    Read the article

  • How to get depth of array in PHP?

    - by user198729
    'test2' => array 'name' => string 'ntuser.dat.LOG' (length=14) 'type' => string 'application/octet-stream' (length=24) 'tmp_name' => string 'D:\wamp\tmp\php224.tmp' (length=22) 'error' => int 0 'size' => int 0 The above should be depth of 2.

    Read the article

  • weird array syntax

    - by dnagirl
    I'm trying to figure how a function I've been given works -- or rather doesn't work. The problematic areas include array notation like this: $small[$end[$i]{0}] I think the idea is to append "0" to the value of $end[$i] and use that for the index of $small. But it doesn't work in PHP5.3. Is this a deprecated syntax and is it trying to do what I think it is?

    Read the article

  • To PHP Namespace or not to PHP Namespace

    - by David
    ok, im relatively new to php programming and have been plodding along quite unaware that it is possible to actually use namespaces in php as I can in c# etc. Its really ugly though as they have decided to use backslashes - why! Anyway, I am interested in other php programmers views on whether namespaces will catch on in php and whether I should begin to use them now?

    Read the article

  • php file creation and how to run my php program

    - by user216112
    I'd like if someone could give me some advice on creating the php file, i know to php language.but where to write it.i have followed some tutorial to run php file in netbeans but its pathethic to download xamp server,apache http server.can u give me the direct of how make configuration and all.i have window7 ultimate and will file i hav to download i don't know. i have netbeans all bundle feature and wamp server.how should i write my php program successfully.plz help me to resolve this.

    Read the article

  • Array from Requests

    - by Joseph Robidoux
    Hi ive set up 2 scripts, both communicating back and forth. One thing id like is for 1 script to post an unknown amount of GETs to the other script. Id like the other script to some how be able to grab all the GETS and put the values in an array.

    Read the article

  • Split an array, not working

    - by Kyle Hudson
    Hi OK I need to figure out how to count how many numbers are in the following example. 07000000000,07000000001,07000000002,07000000003,07000000004 etc... I have tried the following PHP functions. explode, implode, count, foreach and for. None of them seemed to have worked and I am really stuck now. Any help will is appriciated. Kyle

    Read the article

  • How to push both value and key into array with php

    - by sombe
    $GET = array(); $key = 'one=1'; $rule = explode('=',$key); /* array_push($GET,$rule[0]=>$rule[1]); */ I'm looking for something like this so that: print_r($GET); /*output:*/ $GET[one=>1,two=>2,...] is there a function to do this (because array_push won't work this way). thanks!

    Read the article

  • design decision between array or object save in database

    - by justjoe
    i code some configuration setting. And need those values to be load, everytime my webapp start. yes, it's somekind autoload setting. But, right now, i have to choose between save it as object or array. is there any different between them when we save them in database ? which one is faster or maintainable or other pro and cons thanks

    Read the article

  • [PHP] converting mysql data into array?

    - by Mahmoud
    i have an ajax script that check if the user name is available or not, but it keeps taking the newest user name and the rest are out $result = mysql_query("Select username from customer"); while ($row = mysql_fetch_array($result)){ $existing_users=array(''.$row['username'].','); } i know i am doing something worng

    Read the article

  • php-fpm + persistent sockets = 502 bad gateway

    - by leeoniya
    Put on your reading glasses - this will be a long-ish one. First, what I'm doing. I'm building a web-app interface for some particularly slow tcp devices. Opening a socket to them takes 200ms and an fwrite/fread cycle takes another 300ms. To reduce the need for both of these actions on each request, I'm opening a persistent tcp socket which reduces the response time by the aforementioned 200ms. I was hoping PHP-FPM would share the persistent connections between requests from different clients (and indeed it does!), but there are some issues which I havent been able to resolve after 2 days of interneting, reading logs and modifying settings. I have somewhat narrowed it down though. Setup: Ubuntu 13.04 x64 Server (fully updated) on Linode PHP 5.5.0-6~raring+1 (fpm-fcgi) nginx/1.5.2 Relevent config: nginx worker_processes 4; php-fpm/pool.d pm = dynamic pm.max_children = 2 pm.start_servers = 2 pm.min_spare_servers = 2 Let's go from coarse to fine detail of what happens. After a fresh start I have 4x nginx processes and 2x php5-fpm processes waiting to handle requests. Then I send requests every couple seconds to the script. The first take a while to open the socket connection and returns with the data in about 500ms, the second returns data in 300ms (yay it's re-using the socket), the third also succeeds in about 300ms, the fourth request = 502 Bad Gateway, same with the 5th. Sixth request once again returns data, except now it took 500ms again. The process repeats for several cycles after which every 4 requests result in 2x 502 Bad Gateways and 2x 500ms Data responses. If I double all the fpm pool values and have 4x php-fpm processes running, the cycles settles in with 4x successful 500ms responses followed by 4x Bad Gateway errors. If I don't use persistent sockets, this issue goes away but then every request is 500ms. What I suspect is happening is the persistent socket keeps each php-fpm process from idling and ties it up, so the next one gets chosen until none are left and as they error out, maybe they are restarted and become available on the next round-robin loop ut the socket dies with the process. I haven't yet checked the 'slowlog', but the nginx error log shows lots of this: *188 recv() failed (104: Connection reset by peer) while reading response header from upstream, client:... All the suggestions on the internet regarding fixing nginx/php-fpm/502 bad gateway relate to high load or fcgi_pass misconfiguration. This is not the case here. Increasing buffers/sizes, changing timeouts, switching from unix socket to tcp socket for fcgi_pass, upping connection limits on the system....none of this stuff applies here. I've had some other success with setting pm = ondemand rather than dynamic, but as soon as the initial fpm-process gets killed off after idling, the persistent socket is gone for all subsequent php-fpm spawns. For the php script, I'm using stream_socket_client() with a STREAM_CLIENT_PERSISTENT flag. A while/stream_select() loop to detect socket data and fread($sock, 4096) to grab the data. I don't call fclose() obviously. If anyone has some additional questions or advice on how to get a persistent socket without tying up the php-fpm processes beyond the request completion, or maybe some other things to try, I'd appreciate it. some useful links: Nginx + php-fpm - recv() error Nginx + php-fpm "504 Gateway Time-out" error with almost zero load (on a test-server) Nginx + PHP-FPM "error 104 Connection reset by peer" causes occasional duplicate posts http://www.linuxquestions.org/questions/programming-9/php-pfsockopen-552084/ http://stackoverflow.com/questions/14268018/concurrent-use-of-a-persistent-php-socket http://devzone.zend.com/303/extension-writing-part-i-introduction-to-php-and-zend/#Heading3 http://stackoverflow.com/questions/242316/how-to-keep-a-php-stream-socket-alive http://php.net/manual/en/install.fpm.configuration.php https://www.google.com/search?q=recv%28%29+failed+%28104:+Connection+reset+by+peer%29+while+reading+response+header+from+upstream+%22502%22&ei=mC1XUrm7F4WQyAHbv4H4AQ&start=10&sa=N&biw=1920&bih=953&dpr=1

    Read the article

  • PHP.ini does not load

    - by Jonathan Park
    Ok this is probably just me not knowing enough about php but here it goes. I'm on Ubuntu Hardy. I have a custom compiled version of PHP which I have compiled with these parameters. ./configure --enable-soap --with-zlib --with-mysql --with-apxs2=[correct path] --with-config-file-path=[correct path] --with-mysqli --with-curlwrappers --with-curl --with-mcrypt I have used the command pecl install pecl_http to install the http.so extension. It is in the correct module directory for my php.ini. My php.ini is loading and I can change things within the ini and effect php. I have included the extension=http.so line in my php.ini. That worked fine. Until I added these compilation options in order to add imap --with-openssl --with-kerberos --with-imap --with-imap-ssl Which failed because I needed the c-client library which I fixed by apt-get install libc-client-dev After which php compiles fine and I have working imap support, woo. HOWEVER, now all my calls to HttpRequest which is part of the pecl_http extention in http.so result in Fatal error: Class 'HttpRequest' not found errors. I figure the http.so module is no longer loading for one reason or another but I cannot find any errors showing the reason. You might say "Have you tried undoing the new imap setup?" To which I will answer. Yes I have. I directly undid all my config changes and uninstalled the c-client library and I still can't get it to work. I thought that's weird... I have made no changes that would have resulted in this issue. After looking at that I have also discovered that not only is the http extension no longer loading but all my extensions loaded via php.ini are no longer loading. Can someone at least give me some further debugging steps? So far I have tried enabling all errors including startup errors in my php.ini which works for other errors, but I'm not seeing any startup errors either on command line or via apache. And yet again the php.ini appears to be being parsed given that if I run php_info() I get settings that are in the php.ini. Edit it appears that only some of the php.ini settings are being listened to. Is there a way to test my php.ini? Edit Edit It appears I am mistaken again and the php.ini is not being loaded at all any longer. However, If I run php_info() I get that it's looking for my php.ini in the correct location. Edit Edit Edit My config is at the config file path location below but it says no config file loaded. WTF Permission issue? It is currently 644 so everyone should be able to read it if not write it. I tried making it 777 and that didn't work. Configuration File (php.ini) Path /etc/php.ini Loaded Configuration File (none) Edit Edit Edit Edit By loading the ini on the command line using the -c command I am able to run my files and using -m shows that my modules load So nothing is wrong with the php.ini

    Read the article

  • PHP search multidimensional array for value, then place that element at start of array

    - by BobFlemming
    I need to search this array: cars - [0] -make : Ford -model: Escort -year: 1991 [1] -make: Honda -model: Civic -year: 1996 [2] -make: Vauxhall -model: Astra -year: 1972 And if (for example) the model is "Civic" , place that 'car' at position 0. So the end array would be like: cars - [0] -make: Honda -model: Civic -year: 1996 [1] -make : Ford -model: Escort -year: 1991 [2] -make: Vauxhall -model: Astra -year: 1972 I've tried some usort variations: function typeSort($a, $b) { if ($a['model'] == 'Civic' ) { return 0; } return ($a['model'] < $b['model']) ? -1 : 1; } but this is just returning 1

    Read the article

  • Populate javascript array with PHP array of Variables

    - by user1704514
    The following code is used to populate a pie chart in javascript: <script type="text/javascript"> var agg = { label: 'Aggressive', pct: [60, 10, 6, 30, 14, 10] }, bal = { label: 'Balanced', pct: [24, 7, 2, 18, 13, 36] }, mod = { label: 'Moderate', pct: [12, 4, 2, 10, 11, 61] }, inc = { label: 'Income', pct: [ 0, 0, 0, 0, 0,100] }, </script> Instead of tm: [40, 60, 67, 30, 74, 50] as seen above, I would like to make each of 6 values a php variable. Like: tm: [$r1, $r2, $r3, $r4, $r5, $r6] . How do I do this? How do I do this with? A php array or json encode?

    Read the article

  • Convert char array to int array c++

    - by Yadira Suazo
    I`m having problems converting a char array read from file to an int array. Maybe someone can help me. This is my code: char vectorPatron[67]; int iPatrones[67]; archivo = fopen("1_0.txt", "r"); for(i=0;i<67;i++){ fscanf(archivo, "%c", &vectorPatron[i]); printf("%c",vectorPatron[i]); } fclose(archivo); for(i=0;i<67;i++){ iPatrones[i] = atoi(&vectorPatron[i]); printf("%d",iPatrones[i]); }

    Read the article

  • Android java assigning 2d array to 3d array

    - by semajhan
    I'm running into problems trying to assign a 2d array to a 3d array, so I thought i'd ask a question about 3d and 2d arrays. Say I have a masterArray[][][] and wanted to put childArray1[][] and childArray2[][] into it. This is how I have done it and was wondering if that is the correct way of applying it: private int[][][] masterArray; private int[][] childArray1 = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 0, 0, 1, 0, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 0, 1, 1, 1, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 0, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 0, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 0, 1, 1, 1, 0, 1}, {1, 0, 1, 1, 0, 1, 8, 1, 0, 1}, {1, 0, 7, 1, 1, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 0, 1, 0, 1}, {1, 0, 1, 1, 1, 1, 1, 1, 0, 1}, {1, 0, 0, 0, 0, 0, 0, 9, 0, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1} }; private int[][] childArray2 = { {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 1}, {1, 1, 1, 1, 7, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 0, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 0, 0, 0, 1, 1, 1}, {1, 1, 1, 9, 1, 1, 8, 0, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, }; Ok, so in my init method I use these some methods to set the child arrays into the master array. What I was curious about was how this exactly works. I assumed the following: masterLevel = new int[MAX_LEVELS][MAP_WIDTH][MAP_HEIGHT]; for (int x = 0; x < MAP_WIDTH; x++) { for (int y = 0; y < MAP_HEIGHT; y++) { masterArray[currentLevel][x][y] = childArray1[x][y]; } } Would that work? In my application things aren't working so I picking out code that I am not 100% sure on.

    Read the article

  • Reverse subarray of an array with O(1)

    - by Babibu
    I have an idea how to implement sub array reverse with O(1), not including precalculation such as reading the input. I will have many reverse operations, and I can't use the trivial solution of O(N). Edit: To be more clear I want to build data structure behind the array with access layer that knows about reversing requests and inverts the indexing logic as necessary when someone wants to iterate over the array. Edit 2: The data structure will only be used for iterations I been reading this and this and even this questions but they aren't helping. There are 3 cases that need to be taking care of: Regular reverse operation Reverse that including reversed area Intersection between reverse and part of other reversed area in the array Here is my implementation for the first two parts, I will need your help with the last one. This is the rule class: class Rule { public int startingIndex; public int weight; } It is used in my basic data structure City: public class City { Rule rule; private static AtomicInteger _counter = new AtomicInteger(-1); public final int id = _counter.incrementAndGet(); @Override public String toString() { return "" + id; } } This is the main class: public class CitiesList implements Iterable<City>, Iterator<City> { private int position; private int direction = 1; private ArrayList<City> cities; private ArrayDeque<City> citiesQeque = new ArrayDeque<>(); private LinkedList<Rule> rulesQeque = new LinkedList<>(); public void init(ArrayList<City> cities) { this.cities = cities; } public void swap(int index1, int index2){ Rule rule = new Rule(); rule.weight = Math.abs(index2 - index1); cities.get(index1).rule = rule; cities.get(index2 + 1).rule = rule; } @Override public void remove() { throw new IllegalStateException("Not implemented"); } @Override public City next() { City city = cities.get(position); if (citiesQeque.peek() == city){ citiesQeque.pop(); changeDirection(); position += (city.rule.weight + 1) * direction; city = cities.get(position); } if(city.rule != null){ if(city.rule != rulesQeque.peekLast()){ rulesQeque.add(city.rule); position += city.rule.weight * direction; changeDirection(); citiesQeque.push(city); } else{ rulesQeque.removeLast(); position += direction; } } else{ position += direction; } return city; } private void changeDirection() { direction *= -1; } @Override public boolean hasNext() { return position < cities.size(); } @Override public Iterator<City> iterator() { position = 0; return this; } } And here is a sample program: public static void main(String[] args) { ArrayList<City> list = new ArrayList<>(); for(int i = 0 ; i < 20; i++){ list.add(new City()); } CitiesList citiesList = new CitiesList(); citiesList.init(list); for (City city : citiesList) { System.out.print(city + " "); } System.out.println("\n******************"); citiesList.swap(4, 8); for (City city : citiesList) { System.out.print(city + " "); } System.out.println("\n******************"); citiesList.swap(2, 15); for (City city : citiesList) { System.out.print(city + " "); } } How do I handle reverse intersections?

    Read the article

  • Output a php multi-dimensional array to a html table

    - by Fireflight
    I have been banging my head against the wall with this one for nearly a week now, and am no closer than I was the first day. I have a form that has 8 columns and a variable number of rows which I need to email to the client in a nicely formatted email. The form submits the needed fields as a multidimensional array. Rough example is below: <input name="order[0][topdiameter]" type="text" id="topdiameter0" value="1" size="5" /> <input name="order[0][bottomdiameter]" type="text" id="bottomdiameter0" value="1" size="5" /> <input name="order[0][slantheight]" type="text" id="slantheight0" value="1" size="5" /> <select name="order[0][fittertype]" id="fittertype0"> <option value="harp">Harp</option> <option value="euro">Euro</option> <option value="bulbclip">Regular</option> </select> <input name="order[0][washerdrop]" type="text" id="washerdrop0" value="1" size="5" /> <select name="order[0][fabrictype]" id="fabrictype"> <option value="linen">Linen</option> <option value="pleated">Pleated</option> </select> <select name="order[0][colours]" id="colours0"> <option value="beige">Beige</option> <option value="white">White</option> <option value="eggshell">Eggshell</option> <option value="parchment">Parchment</option> </select> <input name="order[0][quantity]" type="text" id="quantity0" value="1" size="5" /> This form is formatted in a table, and rows can be added to it dynamically. What I've been unable to do is get a properly formatted table out of the array. This is what I'm using now (grabbed from the net). <?php if (isset($_POST["submit"])) { $arr= $_POST['order'] echo '<table>'; foreach($arr as $arrs) { echo '<tr>'; foreach($arrs as $item) { echo "<td>$item</td>"; } echo '</tr>'; } echo '</table>; }; ?> This works perfectly for a single row of data. If I try submitting 2 or more rows from the form then one of the columns disappears. I'd like the table to be formatted as: | top | Bottom | Slant | Fitter | Washer | Fabric | Colours | Quantity | ------------------------------------------------------------------------ |value| value | value | value | value | value | value | value | with additional rows as needed. But, I can't find any examples that will generate that type of table! It seems like this should be something fairly straightforward, but I just can't locate an example that works the way I need it too.

    Read the article

< Previous Page | 27 28 29 30 31 32 33 34 35 36 37 38  | Next Page >