Search Results

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

Page 26/1708 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • PHP function generate UL LI

    - by apis17
    hi.. i'm referring this address for function olLiTree http://stackoverflow.com/questions/753853/php-function-that-creates-a-nested-ul-li i have this array $tree = array("A"=array("B"=array("C"="C","D"="D"),"E"=array("F"="F","G"="G"))); but not able to use this function function olLiTree($tree) { echo '<ul>'; foreach($tree as $item) { if (is_array($item)) { olLiTree($item); } else { echo '<li>', $item, '</li>'; } } echo '</ul>'; } to generate <ul> <li>A</li> <li>B <ul> <li>C</li> <li>D</li> </ul> </li> <li>E <ul> <li>F </li> </ul> </li> <ul> <li>G</li> </ul> </ul> can anybody help me to fix this? thanks..

    Read the article

  • PHP Stop Word List

    - by Dom Hodgson
    I'm playing about with a stop words within my code I have an array full of words that I'd like to check, and an array of words I want to check against. At the moment I'm looping through the array one at at a time and removing the word if its in_array vs the stop word list but I wonder if there's a better way of doing it, I've looked at array_diff and such however if I have multiple stop words in the first array, array_diff only appears to remove the first occurrence. The focus is on speed and memory usage but speed more so. Thanks

    Read the article

  • Apache mod php and script invocation

    - by Abhi
    Say I am running a PHP script, foo.php, inside apache configured with mod php, then, say I invoke the script from my browser(or any other means), does apache spawn off a new process in which the script gets executed? How does it work? Can someone pls point me to some good article on this?

    Read the article

  • using nested arrays by php http_build_query() and recieve them in flash AS3

    - by Mahmoud
    hi, i am having this hard time figuring what is needed to do, i am using URLVariables to send/recieve values between flash and PHP the problem is, i am unable to access nested arrays ( array inside an array ) with flash heres an example: $dgresult = array("total" = $results); echo http_build_query($dgresult,"flf_"); in flash, all i need to do is to use: var variables:URLVariables = new URLVariables(e.target.data); then i can access it with : variables.total the problem now is when i have nested arrays: $dgresult = array("total" = $results); array_push($dgresult,$another_array); http_build_query($dgresult,"flf_"); i can still access variables.total but what about anything that has flf_ ? how is that possible?

    Read the article

  • PHP: Array of objects is empty when I come to retrieve one from the array

    - by Tom
    Good morning, I am trying to load rows from a database and then create objects from them and add these objects to a private array. Here are my classes: <?php include("databaseconnect.php"); class stationItem { private $code = ''; private $description = ''; public function setCode($code ){ $this->code = $code; } public function getCode(){ return $this->code; } public function setDescription($description){ $this->description = $description; } public function getDescription(){ return $this->description; } } class stationList { private $stationListing; function __construct() { connect(); $stationListing = array(); $result = mysql_query('SELECT * FROM stations'); while ($row = mysql_fetch_assoc($result)) { $station = new stationItem(); $station->setCode($row['code']); $station->setDescription($row['description']); array_push($stationListing, $station); } mysql_free_result($result); } public function getStation($index){ return $stationListing[$index]; } } ?> As you can see I am creating a stationItem object per database row (which for now has a code and description) and I then push these on to the end of my array which is held as a private variable in stationList. This is code which creates this classes and attempts to access the properties on them: $stations = new stationList(); $station = $stations->getStation(0); echo $station->getCode(); I am finding that the sizeof($stationList) at the end of the constructor is 1 but then it is zero when we come to try to get an object from the array using the index. Therefore the error that I get is: Fatal error: Call to a member function getCode() on a non-object Please can someone explain to me why this is happening? I guess I am misunderstanding how object references work in PHP5.

    Read the article

  • How can I use PHP Mail() function within PHP-FPM? On Nginx?

    - by TheBlackBenzKid
    I have searched everywhere for this and I really want to resolve this. In the past I just end up using an SMTP service like SendGrid for PHP and a mailing plugin like SwiftMailer. However I want to use PHP. Basically my setup (I am new to server setup, and this is my personal setup following a tutorial) Nginx Rackspace Cloud PHP 5.3 PHP-FPM Ubuntu 11.04 My phpinfo() returns this about the Mail entries: mail.log no value mail.add_x_header On mail.force_extra_parameters no value sendmail_from no value sendmail_path /usr/sbin/sendmail -t -i SMTP localhost smtp_port 25 Can someone help me to as why Mail() will not work - my script is working on all other sites, it is a normal mail command. Do I need to setup logs or enable some PHP port on the server? My Sample script <? # FORMS VARS // $to = $customers_email; // $to = $customers_email; $to = $_GET["customerEmailFromForm"]; $subject = "Thank you for contacting Real-Domain.com"; $message = " <html> <head> </head> <body> Thanks, your message was sent and our team will be in touch shortly. <img src='http://cdn.com/emails/thank_you.jpg' /> </body> </html> "; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n"; $headers .= 'From: <[email protected]>' . "\r\n"; // SEND MAIL mail($to,$subject,$message,$headers); ?> Thanks

    Read the article

  • 'Overwrite' php.ini settings

    - by incrediman
    I have a folder, and for all php files in that folder (or even better, in that folder or any folders within it) I'd like to make some changes to the php settings. Can I just place a php.ini file in that folder with those settings I'd like to change? If so, any reason why this wouldn't be working for me? It's my own server. Thanks!

    Read the article

  • Efficient way of calculating average difference of array elements from array average value

    - by Saysmaster
    Is there a way to calculate the average distance of array elements from array average value, by only "visiting" each array element once? (I search for an algorithm) Example: Array : [ 1 , 5 , 4 , 9 , 6 ] Average : ( 1 + 5 + 4 + 9 + 6 ) / 5 = 5 Distance Array : [|1-5|, |5-5|, |4-5|, |9-5|, |6-5|] = [4 , 0 , 1 , 4 , 1 ] Average Distance : ( 4 + 0 + 1 + 4 + 1 ) / 5 = 2 The simple algorithm needs 2 passes. 1st pass) Reads and accumulates values, then divides the result by array length to calculate average value of array elements. 2nd pass) Reads values, accumulates each one's distance from the previously calculated average value, and then divides the result by array length to find the average distance of the elements from the average value of the array. The two passes are identical. It is the classic algorithm of calculating the average of a set of values. The first one takes as input the elements of the array, the second one the distances of each element from the array's average value. Calculating the average can be modified to not accumulate the values, but caclulating the average "on the fly" as we sequentialy read the elements from the array. The formula is: Compute Running Average of Array's elements ------------------------------------------- RA[i] = E[i] {for i == 1} RA[i] = RA[i-1] - RA[i-1]/i + A[i]/i { for i > 1 } Where A[x] is the array's element at position x, RA[x] is the average of the array's elements between position 1 and x (running average). My question is: Is there a similar algorithm, to calculate "on the fly" (as we read the array's elements), the average distance of the elements from the array's mean value? The problem is that, as we read the array's elements, the final average value of the array is not known. Only the running average is known. So calculating differences from the running average will not yield the correct result. I suppose, if such algorithm exists, it probably should have the "ability" to compensate, in a way, on each new element read for the error calculated as far.

    Read the article

  • Figure out if element is present in multi-dimensional array in python

    - by Terje
    I am parsing a log containing nicknames and hostnames. I want to end up with an array that contains the hostname and the latest used nickname. I have the following code, which only creates a list over the hostnames: hostnames = [] # while(parsing): # nick = nick_on_current_line # host = host_on_current_line if host in hostnames: # Hostname is already present. pass else: # Hostname is not present hostnames.append(host) print hostnames # ['[email protected]', '[email protected]', '[email protected]'] I thought it would be nice to end up with something along the lines of the following: # [['[email protected]', 'John'], ['[email protected]', 'Mary'], ['[email protected]', 'Joe']] My problem is finding out if the hostname is present in such a list hostnames = [] # while(parsing): # nick = nick_on_current_line # host = host_on_current_line if host in hostnames[0]: # This doesn't work. # Hostname is already present. # Somehow check if the nick stored together # with the hostname is the latest one else: # Hostname is not present hostnames.append([host, nick]) Are there any easy fix to this, or should I try a different approach? I could always have an array with objects or structs (if there is such a thing in python), but I would prefer a solution to my array problem.

    Read the article

  • What are those little useful ,customize/enhanced php functions that you wish you knew about 2 years

    - by I Like PHP
    Hello All, i like to work in php bcoz it's just amazing language. please share basic, useful, enhanced and customize function that make things better and easy in php and must be used in our all PHP project, i m sharing some of them please share your customize function that may be useful for everyone alternative/ enhanced print_r() and var_dump() function watch( $what ) { echo '<pre>'; if ( is_array( $what ) ) { print_r ( $what ); } else { var_dump ( $what ); } echo '</pre>'; } usage: 1. watch($_POST); // to see all post variable 2. watch($array); // to see any variable may b array, string or a variable enhanced mysql_escape_string() for multidimensional array to prevent sql injection function recursive_escape(&$value) { if (is_array($value)) array_map('recursive_escape', $value); else $value = mysql_escape_string($value); } usage array_map('recursive_escape', $_POST); ---------------------For encoding Get variables-------------------------------------- function nkode($k) { if ( is_array( $k ) ) return array_map("base64_encode",$k); else return base64_encode($k); } ---------------------for decoding varaibles from GET--------------------------------- function dkode($k) { if ( is_array( $k ) ) return array_map("base64_decode",$k); else return base64_decode($k); } Usage <a href="somelink.php?pid=<?php echo nkode($someid)?>"> and on next page(somelink.php) $findID=dkode($_GET[pid]); date convert to mm/dd/yyyy to yyyy-mm-dd( if we use date datatype in mysql) and also change into mm/dd/yyyy to disply on page function dateconvert($date,$func) { if ($func == 1){ //insert conversion list($month, $day, $year) = split('[/.-]', $date); $date = "$year-$month-$day"; return $date; } if ($func == 2){ //output conversion list($year, $month, $day) = split('[-.]', $date); $date = "$month/$day/$year"; return $date; } } usage $firstDate=dateconvert($_POST['firstdate'],1); // for insertion in database $showDate=dateconvert($fetch->date_field,2) // to display on browser to clean data before doing some action with that variable function cleanID($data) { $success=0; $data=trim($data); $data=strtolower($data); $data=strip_tags($data); return $data; } usage cleanID($_POST[username]); cleanID($_GET[pid]); please share any basic function that must be used , and please give me some suggestion to make above function more better Thanks

    Read the article

  • Debugging php-cli scripts with xdebug and netbeans?

    - by wurdalack
    I have managed to initiate php-cli script debug session from the IDE itself, but I need to start the debugging session from the shell / command line. These are rather complex maintenance PHP scripts which take a lot of input parameters, so entering arguments from within Netbeans is a bit cumbersome. I have done it before with Zend studio http://kb.zend.com/index.php?View=entry&EntryID=130 but now I need to get it working with Netbeans. Thanks in advance.

    Read the article

  • PHP .htaccess issue, specific/dynamic keywords

    - by Kunal
    Here goes my .htaccess file's content. Options +FollowSymLinks RewriteEngine On RewriteRule ^online-products$ products.php?type=online RewriteRule ^land-products$ products.php?type=land RewriteRule ^payment-methods$ payment-methods.php RewriteRule ^withdrawal-methods$ withdrawal-methods.php RewriteRule ^deposit-methods$ deposit-methods.php RewriteRule ^product-bonuses$ product-bonuses.php RewriteRule ^law-and-regulations$ law-and-regulations.php RewriteRule ^product-news$ product-news.php RewriteRule ^product-games$ product-games.php RewriteRule ^no-products$ no-products.php RewriteRule ^page-not-found$ notfound.php RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^casinos/(.*)$ product.php?id=$1 RewriteCond %{SCRIPT_FILENAME} !-f RewriteCond %{SCRIPT_FILENAME} !-d RewriteRule ^(.*)$ cms.php?link=$1 ErrorDocument 404 /notfound.php What I am trying to achive here is that the first set of rules apply to some specific keywords which should redirect to specific hard coded pages. But anything else parat from those keywords should redirect to cms.php as a parameter as you can see. But the problem is that every keyword is getting redirected to cms.php. Whereas I want any other keyword apart from which are already hard coded in .htaccess file should go cms.php. Not just every keyword. Example: www.sitename.com/online-products -> www.sitename.com/products.php?type=online www.sitename.com/about-the-website -> www.sitename.com/cms.php?id=about-the-website www.sitename.com/product-news -> www.sitename.com/product-news.php Also another issue I am facing is I can not use any keyword with space. Like "online-products" is fine, but I can't use "online products". Please help me out with your expert knowledge. Many thanks in advance for your kind help. Appreciate it.

    Read the article

  • remove values from an array php

    - by LiveEn
    I have a array of links and i have another array which contains certain values i would like to filter in the list eg: http://www.liquidshredder.co.uk/shop%3Fkw%3Dsurfboards%26fl%3D330343%26ci%3D3889610385%26network%3Ds http://www.bournemouth-surfing.co.uk/index.php%3FcPath%3D32 http://www.stcstores.co.uk/wetsuit-range-sizing--pricing-info-1-w.asp http://www.kingofwatersports.com/wetsuit-sale-c227.html http://www.uk.best-price.com/search/landing/query/bodyboards/s/google/altk/Surf%2Band/koid/1944273223/ http://www.surfinghardware.co.uk/Results.cfm%3Fcategory%3D20%26kw%3Dbodyboards%26fl%3D11407%26ci%3D3326979552%26network%3Ds http://www.teste.co.uk/adtrack/baod.html http://www.teste.co.uk/bodyboards/ www.sandskater.co.uk/ www.sandskater.co.uk/bodyboards/+Bodyboards&sa=X&ei=GwSWS-KaGM24rAeF-vCKDA&ved=0CBMQHzAKOAo http://www.extremesportstrader.co.uk/buy/water/bodyboarding/ www.extremesportstrader.co.uk/buy/water/bodyboarding/+Bodyboards&sa=X&ei=GwSWS-KaGM24rAeF-vCKDA&ved=0CBYQHzALOAo www.circle-one.co.uk/+Bodyboards&sa=X&ei=GwSWS-KaGM24rAeF-vCKDA&ved=0CBkQHzAMOAo http://www.teste.co.uk/bodyboards/p1 http://www.teste.co.uk/bodyboards/p2 http://www.amazon.co.uk/s/%3Fie%3DUTF8%26keywords%3Dbodyboards%26tag%3Dgooghydr-21%26index%3Daps%26hvadid%3D4764625891%26ref%3Dpd_sl_2lyzsfw1ar_e http://www.teste.co.uk/bodyboards/p3 www.extremesportstrader.co.uk/buy/water/ and i would like to remove all the instances of "http://www.teste.co.uk"? i tried the below code but it doesn't work :( $remove=array("teste.co.uk","127.0.0.1","localhost","wikipedia.org","gmail.com","answers.yahoo.com"); foreach ($list[0] as $key=>$clean) { if (in_array($clean,$remove)) { unset($list[0][$key]); } echo $clean; echo '<br>'; }

    Read the article

  • jquery - array problem help pls.

    - by russp
    Sorry folks, I really need help with posting an array problem. I would imaging it's quite simple, but beyond me. I have this JQuery function (using sortables) $(function() { $("#col1, #col2, #col3, #col4").sortable({ connectWith: '.column', items: '.portlet:not(.ui-state-disabled)', stop : function () { serial_1 = $('#col1').sortable('serialize'); serial_2 = $('#col2').sortable('serialize'); serial_3 = $('#col3').sortable('serialize'); serial_4 = $('#col4').sortable('serialize'); } }); }); Now I can post it to a database like this, and I can loop this ajax through all 4 "serials" $.ajax({ url: "test.php", type: "post", data: serial_1, error: function(){ alert(testit); } }); But that is not what I want to do as it creates 4 rows in the DB table. I want/need to create a single "nested array" from the 4 serials so that it enters the DB as 1 (one) row. My "base" database data looks like this: a:4:{s:4:"col1";a:3:{i:1;s:6:"forums";i:2;s:4:"chat";i:3;s:5:"blogs";}s:4:"col2";a:2:{i:1;s:5:"pages";i:2;s:7:"members";}s:4:"col3";a:2:{i:1;s:9:"galleries";i:2;s:4:"shop";}s:4:"col4";a:1:{i:1;s:4:"news";}} Therefore the JQuery array should "replicate" and create it (obviously will change on sorting) Help please thanks in advance

    Read the article

  • php - usort or array_multisort?

    - by Simpson88Keys
    Trying to sort the array below by memnum in ascending order, and I'm a bit confused which is better to use... usort or array_multisort? I was thinking usort because it's multidimensional? Does anyone have an example of this? Array ( [0] => Array ( [memnum] => 3236467423 [mid] => 1104881300 [fname] => JOHN [lname] => DOE [add1] => OMITTED [add2] => [city] => CHESTERFIELD [state] => MI [zip] => 48051 [age] => 50 ) [1] => Array ( [memnum] => 3258467922 [mid] => 1105121457 [fname] => JANE [lname] => DOE [add1] => OMITTED [add2] => [city] => CHESTERFIELD [state] => MI [zip] => 48051 [age] => 50 ) [2] => Array ( [memnum] => 3237769108 [mid] => 1104489312 [fname] => BOB [lname] => DOE [add1] => OMITTED [add2] => [city] => CHESTERFIELD [state] => MI [zip] => 48051 [age] => 50 ) )

    Read the article

  • PHP , How can I get values out of a complex array ?

    - by Joe appleton
    I am calling a soap function that returns the following array: Array ( [FastAddressResult] = Array ( [IsError] = false [ErrorNumber] = 0 [ErrorMessage] = [Results] = Array ( [Address] = Array ( [Id] = 13872147.00 [OrganisationName] = [DepartmentName] = [Line1] = Methley Grove [Line2] = [Line3] = [Line4] = [Line5] = [PostTown] = Leeds [County] = West Yorkshire [Postcode] = LS7 3PA [Mailsort] = 64121 [Barcode] = [IsResidential] = false [IsSmallOrganisation] = false [IsLargeOrganisation] = false [RawData] = [GeographicData] = Array ( [GridEastM] = 0 [GridNorthM] = 0 [Objective2] = false [Transitional] = false [Longitude] = 0 [Latitude] = 0 [WGS84Longitude] = 0 [WGS84Latitude] = 0 ) ) ) ) I need to exstract the values the following does not seem to work:          $this-adressline1 = $result-FastAddressResult-Results-Address-Line1; Any ideas ?

    Read the article

  • PHP Form Validation

    - by JM4
    This question will undoubtedly be difficult to answer and ask in a way that makes sense but I'll try my best: I have a form which uses PHP to display certain sections of the form such as: <?php if ($_SESSION['EnrType'] == "Individual") { display only form information for individual enrollment } ?> and <?php if ($_SESSION['Num_Enrs'] > 6) { display only form information for 7 total members enrollment } ?> In each form piece, unique information is collected about each enrollee but the basic criteria for each enrollee is the same, i.e. All enrollee's must use have a value in the FirstName field. Each field is named according to the enrollee number, i.e. Num1FirstName; Num2FirstName. I have a PHP validation script which is absolutely fantastic and am not looking to change it but the issue I am running into is duplication of the script in order to validate ALL fields in one swoop. On submission, all POSTED items are run through my validation script and based on the rules set return an error if they do not equal true. Sample code: if (isset($_POST['submit'])) { // import the validation library require("validation.php"); $rules = array(); // stores the validation rules //All Enrollee Rules $rules[] = "required,Num1FirstName,Num2FirstName,The First Name field is required."; The script above does the following, $rules[] ="REQUIREMENT,fieldname,error message" where requirement gives criteria (in this case, simply that a value is passed), fieldname is the name of the field being validated, and error message returns the error used. My Goal is to use the same formula above and have $rules[] run through ALL firstnames and return the error posted ONLY if they exist (i.e. dont check for member #7's first name if it doesnt exist on the screen). If I simply put a comma between the 'fieldnames' this only checks for the first, then second, and so on so this wont work. Any ideas?

    Read the article

  • PHP database selection issue

    - by Citroenfris
    I'm in a bit of a pickle with freshening up my PHP a bit, it's been about 3 years since I last coded in PHP. Any insights are welcomed! I'll give you as much information as I possibly can to resolve this error so here goes! Files config.php database.php news.php BLnews.php index.php Includes config.php - news.php database.php - news.php news.php - BLnews.php BLnews.php - index.php Now the problem with my current code is that the database connection is being made but my database refuses to be selected. The query I have should work but due to my database not getting selected it's kind of annoying to get any data exchange going! database.php <?php class Database { //------------------------------------------- // Connects to the database //------------------------------------------- function connect() { if (isset($dbhost) && isset($dbuser) && isset($dbpass)) { $con = mysql_connect($dbhost, $dbuser, $dbpass) or die("Could not connect: " . mysql_error()); } }// end function connect function selectDB() { if (isset($dbname) && isset($con)) { $selected_db = mysql_select_db($dbname, $con) or die("Could not select test DB"); } } } // end class Database ?> News.php <?php // include the config file and database class include 'config.php'; include 'database.php'; ... ?> BLnews.php <?php // include the news class include 'news.php'; // create an instance of the Database class and call it $db $db = new Database; $db -> connect(); $db->selectDB(); class BLnews { function getNews() { $sql = "SELECT * FROM news"; if (isset($sql)) { $result = mysql_query($sql) or die("Could not execute query. Reason: " .mysql_error()); } return $result; } ?> index.php <?php ... include 'includes/BLnews.php'; $blNews = new BLnews(); $news = $blNews->getNews(); ?> ... <?php while($row = mysql_fetch_array($news)) { echo '<div class="post">'; echo '<h2><a href="#"> ' . $row["title"] .'</a></h2>'; echo '<p class="post-info">Posted by <a href="#"> </a> | <span class="date"> Posted on <a href="#">' . $row["date"] . '</a></span></p>'; echo $row["content"]; echo '</div>'; } ?> Well this is pretty much everything that should get the information going however due to the mysql_error in $result = mysql_query($sql) or die("Could not execute query. Reason: " .mysql_error()); I can see the error and it says: Could not execute query. Reason: No database selected I honestly have no idea why it would not work and I've been fiddling with it for quite some time now. Help is most welcomed and I thank you in advance! Greets Lemon

    Read the article

  • How to implement callback methods inside classes (PHP)

    - by sombe
    I need to use a class callback method on an array inside another method (the callback function belongs to the class). class Database { public function escape_string_for_db($string){ return mysql_real_escape_string($string); } public function escape_all_array($array){ return array_filter($array,"$this->escape_string_for_db"); } } Is this the right way to go about that? (I mean, in terms of the second parameter passed to array_filter)

    Read the article

  • How to find every possible combination of an arbitrary number of arrays in PHP

    - by Travis
    I have an arbitrary number of nested arrays in php. For example: Array ( [0] => Array ( [0] => 36 [0] => 2 [0] => 9 ) [1] => Array ( [0] => 95 [1] => 21 [2] => 102 [3] => 38 ) [2] => Array ( [0] => 3 [1] => 5 ) ) I want to find the most efficient way to combine all possible combinations of each of these nested arrays. I'd like to end up with something that looks like this... Array ( [0] => "36,95,3" [1] => "36,95,5" [2] => "36,21,3" [3] => "36,21,5" etc... ) The order the results are combined in is not important. That is to say, there is no difference between "3,95,36", "36,95,3", and "95,36,3". I would like to omit these redundant combinations. Any suggestions on how to go about this would be much appreciated. Thanks in advance,

    Read the article

  • Collect all fields in form to an array

    - by Industrial
    Hi everyone, Each div with the class "row" is added upon request from the user, to be able to add multiple items at once. So now is the question how I'll collect all the forms in to an array that PHP can read (like JSON for instance). I'll guess that there's already some easy and effective way of doing this? <div class="container"> <div class="row"> <input type="text" name="value1" id="textfield" /> <input type="text" name="value2" id="textfield" /> <input type="text" name="value3" id="textfield" /> </div> </div> Here's what I would like to achieve out of the shown example: array( array ('value1' => '', 'value2' => '', 'value3' => '') ); Thanks! Update: The form will be handled with PHP and it would be super to be able to do something like a foreach loop on the specific container-div content.

    Read the article

  • Another php array looping question

    - by Dan
    Been battling with this one for what seems, like forever. I have an array: $url_array It contains this info: Array ( [ppp] => Array ( [0] => stdClass Object ( [id] => 46660 [entity_id] => 0 [redirect_url] => http://www.google.com [type] => Image ) [1] => stdClass Object ( [id] => 52662 [entity_id] => 0 [pixel_redirect_url] => http://www.yahoo.com [type] => Image ) [2] => stdClass Object ( [id] => 53877 [entity_id] => 0 [redirect_url] => http://www.msn.com [pixel_type] => Image ) ) [total_count] => 3 ) I need to loop through it, and do things to each variable. I can get this to work: foreach ($piggies_array as $key => $value) { $id = $value[0]->id; $redirect_url = $value[0]->redirect_url; } Not unsurprisingly, it's only echoing the first value of those variables, but no matter what I try I cannot get it to loop through: $value->redirect_url; $value=>redirect_url; I would appreciate any help.

    Read the article

  • PHP: Check if 0?

    - by tarnfeld
    Hi, I am using a class which returns me the value of a particular row and cell of an excel spreadsheet. To build up an array of one column I am counting the rows and then looping through that number with a for() loop and then using the $array[] = $value to set the incrementing array object's value. This works great if none of the values in a cell are 0. The class returns me a number 0 so it's nothing to do with the class, I think it's the way I am looping through the rows and then assigning them to the array... I want to carry through the 0 value because I am creating graphs with the data afterwards, here is the code I have. // Get Rainfall $rainfall = array(); for($i=1;$i<=$count;$i++) { if($data->val($i,2) != 'Rainfall') // Check if not the column title { $rainfall[] = $data->val($i,2); } } For your info $data is the excel spreadsheet object and the method $data->val(row,col) is what returns me the value. In this case I am getting data from column 2. Screenshot of spreadsheet http://cl.ly/1Dmy Thanks! All help is very much appreciated!

    Read the article

  • Can this be done in 1 line? [PHP]

    - by Angelo
    Can this be done in 1 line with PHP? Would be awesome if it could: $out = array("foo","bar"); echo $out[0]; Something such as: echo array("foo","bar")[0]; Unfortunately that's not possible. Would it be possible like this? So I can do this for example in 1 line: echo array(rand(1,100), rand(1000,2000))[rand(0,1)];

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >