PHP - Grabbing A Substring Between Two Strings.
Let's say I have the string "Bob is my friend. Bob likes to eat apples. Goodbye!".
I give a function that string, and the two strings "Bob" and "apples". It returns "Bob likes to eat apples". I seem to have trouble making this function. If I wanted it to return "Bob is my friend. Bob likes to eat apples" that would be much simpler, but I am trying to get the smallest amount of characters between the two strings. I tried doing this, but seem to either get stuck on an infinite loop or return the entire inputted string. Code: [Select] function between($strIn, $str1, $str2){ $pos2 = stripos($strIn, $str2); $pos = 1; $strStore = ""; while($pos>0 && $pos<$pos2){ $pos = stripos($strIn, $str1); $strStore = substr($strin, $pos, $pos2-$pos); $strIn = substr_replace($srtIn, $strtemp, ""); } return $strStore; } What it does it finds the first occurrence of "apples" ($str1) and then keeps finding and deleting every occurrence of "Bob" ($str2) until the position of "Bob" surpasses the position of "apples". As you can tell, it doesn't work. Could anyone help me out, or tell me what I am doing wrong? Similar TutorialsFolks, I want to extract something from a URL, i think we need to use regex for this. Example URL: Code: [Select] http://www.amazon.co.uk/gp/aw/d/B004JN01LW/ref=mp_s_a_1?qid=1305169492&sr=8-1 What we need to Extract: So we need to extract B004JN01LW from the URL. I tried to use substr() but i think its not useful for this purpose, can someone help me with Regex to extract this? Cheers Natasha So I have a database with a bunch of dates in it. In this format 05/15/2011. And this is how I get that out. $data = mysql_query("SELECT * FROM location ORDER BY id ASC") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { $date = $info['date']; }; echo "$date"; The resulted echo would be 05/26/2011 How do I get $date to echo out JUST 05? I'm trying to isolate the month. I think the method is using substrings, but I havent had any luck. Thanks any help would be great! I am using tinyMCE editor and uploading image from it.After form is submitted,it makes textarea's values as <img width="\"65\"" height="\"66\"" alt="\\"" src="\"images/logo.gif\""> cuz of wrong html,it is not displaying image.I tried to replace $_POST['elm2'] = str_replace('"\"','\"',$_POST['elm2']); $_POST['elm2'] = str_replace('\""','\"',$_POST['elm2']); but it is not replacing.How can i correct the HTML so that i display image. Hi, how do I extract a substring? I just want to store "car" in a variable for other uses: Here is the original string: car/red/blue/gun/hit Any help much appreciated! Hello, Does anyone know how to get a substrig by referencing other substrings around it? Ie, my string is the following: These are my favorite foods: <ul> <li id="1"> Pizza </li> <li id="2"> Burgers </li> <li id="three"> Hot Dogs </li> </ul> I need to get the ID of each list item, i know they will always follow "<li id=". I also need to get the text of each list item, i know they will always be before "</li>" Thanks! This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=308768.0 Hey all, I have method like this: Code: [Select] echo tinymce_tag($post->body); Basically the body property contains a string from database containing one or many paragraphs delimited by p tags: Code: [Select] <p>Hello World.</p> <p>Goodbye World.</p> I want to give all the paragraphs a class. This function will give the first p tag a class: Code: [Select] if ( ! function_exists('tinymce_tag')){ function tinymce_tag($content = ''){ $pos = strpos($content, '<p>'); if($pos !== false){ $content = substr_replace($content,' class="paragraph_styler"', 2, 0); } return $content; } } But I am not sure how to give all the p tags in the content variable a class. Thanks for response. I know you can use str_replace to replace a value with another value, or an array of values with an array of other values. What I'd like to do is replace each instance of a single value with an array of values which get iterated through for each instance found. Think prepared statements that you don't have to call setString or setInt on. Here's a made up example. Code: [Select] $db->query = 'SELECT * FROM users WHERE user_name = ? AND user_role = ?; $db->params = array('hopelessX','admin'); $db->executeQuery(); //this contains a call to a private function that does the replace I have everything else working except this. It works if I specify an array of values to replace and do something like below, but I was hoping to not have to support that method of replace if I didn't need to. Code: [Select] $db->query = 'SELECT * FROM users WHERE user_name = :name AND user_role = :role; $db->replace = array(':name',':role'); $db->params = array('hopelessX','admin'); $db->executeQuery(); //this contains a call to a private function that does the replace I can do it that way if I need to or I could make some overly complicated thing that finds each instance of the question mark, replaces it with a unique value and then adds that unique value to a replace array similarly to the method in code block two but that defeats to the purpose of making this simple database adapter in the first place (although it was mostly just for fun anyway). Anyway, if anyone has any advice and knows of a simple means to achieve this goal that would be much appreciated. Thanks in advance This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=321386.0 I am trying to have a search bar and this is the search results page. However when they search they have the option to type in anything and it will search the entire directory for what ever they type in so if they type in "Dog" I want dog to be searched for in the database under title and author this is the code I have now...can anyone help me?? Code: [Select] // Build SQL Query $query = "select * from videos where title like \"%$trimmed%\" order by id DESC"; // EDIT HERE and specify your table and field names for the SQL query Hi guys...
I was at home and doing some coding and stumbled across and API for a computer game called Battlefield 4
http://api.bf4stats....ApRiL&output=js;
I was checking it out and it is a LOT of data. I was wondering if its possible to only pull certain data from the API, say for instance you only want to pull your user name, ID, and what game you are playing (those are the top 3 things). How would you pull only those 3 stats and display that information on say a webpage for you?
thanks guys
JL
I think this belongs here, but my $_POST['gender'] won't grab the gender that was submitted through a form. I am using AJAX so the page doesn't have to reload so it can go in a smooth transition, but the AJAX is grabbing the value perfectly fine. I have a feeling the $_POST isn't grabbing the value because the page isn't reloading.. but I don't want to reload it. These codes are all on the same page. Here is my Javascript: Code: [Select] <script> function chooseGender() { var gender = $('input[name=gender]:checked', '#submitgender').val(); if(gender) { $.ajax( { type: "POST", url: window.location.pathname, data: gender, success: function() { alert("You have chosen to be a " + gender); //It's grabbing it perfectly fine! $("#submitgender").hide(); //It hides the gender table so they can't choose a gender since they already have chosen one. $("#rest").fadeIn(); //Shows the other table that's labeled "rest" as it's ID so they can choose what base, eyes, etc for that specific gender they've chosen. } }); } else { alert('Select a gender.'); } } $(function tabs() { $( "#tabs" ).tabs(); }); </script> But here is the PHP inside the #rest table: Code: [Select] <?php $gender = $_POST['gender']; $sql = "SELECT * FROM habases WHERE gender='".$gender."'"; $result = mysqli_query($cxn, $sql) or die(mysqli_error($cxn)); print_r($sql); while ($row = mysqli_fetch_assoc($result)) { $baseimage = $row['image']; $baseskin = $row['skin']; echo "<img src=\"http://www.elvonica.com/".$baseimage."\" value=\"".$baseskin."\">"; } ?> And this is what I'm getting for the print_r: Quote SELECT * FROM habases WHERE gender='' Currently I am using this very popular code to get all the football scores: Code: [Select] $title = $params->get('title'); $fontc = $params->get('fontc'); $fonts = $params->get('fonts'); //this array contains sports and their URLs $sports = array( "NFL" => "http://sports.espn.go.com/nfl/bottomline/scores"); $results = array(); foreach ( $sports as $sport => $url ) { //get the page pointed to by $url $page = file_get_contents($url); //grab all variables out of the page preg_match_all("/&([^=]+)=([^&]+)/", urldecode($page), $foo); //loop through all the variables on the page foreach ( $foo[1] as $key => $value ) { //debug output, you can delete this next line //echo "{$value} = {$foo[2][$key]}\t<br />\n"; //this chain of IF/elseif statements is used to determine which pattern to use //to strip out the correct data, since each sport seems to have its own format //for the variables you'd "want" if ( $sport == "NFL" && preg_match("/s_left\d+/", $value) ) { $results[$sport][] = $foo[2][$key]; } } } //calculate the sport with the most number of rows $limit = 0; foreach ( $results as $countMe ) { $limit = max($limit, count($countMe)); } //spit out the table with the right headers echo "<td><b> $title </b></td><br><BR>"; "<table border=4 cellpadding=10><tr><th>" . implode("</th><th>", array_keys($sports)). "</th></tr>" ; //loop until you reach the max number of rows, printing out all the table rows you want for ( $p = 0; $p < $limit; $p++ ) { foreach ( array_keys($sports) as $sport );{ $change = str_replace('^','<font color=green><b>W</b> </font>' ,$results[$sport][$p]); $final = str_replace('(FINAL)','<font color=red>(FINAL)', $change); echo "<td><font color=$fonts size=$fontc><b>$final</b></font></td><br>"; } echo "</tr>"; } //kill the table echo "</table>"; and it works fantastically well however.... I'd only like to get certain data say like the Cowboys game info and nothing more... NOT too sure how to do this, I'm just not really sure how to read the page, grab only that data. Help would be greatly appreciated! Thank you. Php Whizzes!
Need to grab geo ip. Why these 2 show data differently ? http://www.geoplugin.net/json.gp?ip=19.117.63.253 http://www.geoplugin.net/php.gp?ip=19.117.63.253 Which one you like ? I like 1st one.
Anyway, is this code any good ? Will it misfire ?
<?php //https://stackoverflow.com/questions/12553160/getting-visitors-country-from-their-ip function ip_info($ip = NULL, $purpose = "location", $deep_detect = TRUE) { $output = NULL; if (filter_var($ip, FILTER_VALIDATE_IP) === FALSE) { $ip = $_SERVER["REMOTE_ADDR"]; if ($deep_detect) { if (filter_var(@$_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; if (filter_var(@$_SERVER['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) $ip = $_SERVER['HTTP_CLIENT_IP']; } } $purpose = str_replace(array("name", "\n", "\t", " ", "-", "_"), NULL, strtolower(trim($purpose))); $support = array("country", "countrycode", "state", "region", "city", "location", "address"); $continents = array( "AF" => "Africa", "AN" => "Antarctica", "AS" => "Asia", "EU" => "Europe", "OC" => "Australia (Oceania)", "NA" => "North America", "SA" => "South America" ); if (filter_var($ip, FILTER_VALIDATE_IP) && in_array($purpose, $support)) { $ipdat = @json_decode(file_get_contents("http://www.geoplugin.net/json.gp?ip=" . $ip)); if (@strlen(trim($ipdat->geoplugin_countryCode)) == 2) { switch ($purpose) { case "location": $output = array( "city" => @$ipdat->geoplugin_city, "state" => @$ipdat->geoplugin_regionName, "country" => @$ipdat->geoplugin_countryName, "country_code" => @$ipdat->geoplugin_countryCode, "continent" => @$continents[strtoupper($ipdat->geoplugin_continentCode)], "continent_code" => @$ipdat->geoplugin_continentCode ); break; case "address": $address = array($ipdat->geoplugin_countryName); if (@strlen($ipdat->geoplugin_regionName) >= 1) $address[] = $ipdat->geoplugin_regionName; if (@strlen($ipdat->geoplugin_city) >= 1) $address[] = $ipdat->geoplugin_city; $output = implode(", ", array_reverse($address)); break; case "city": $output = @$ipdat->geoplugin_city; break; case "state": $output = @$ipdat->geoplugin_regionName; break; case "region": $output = @$ipdat->geoplugin_regionName; break; case "country": $output = @$ipdat->geoplugin_countryName; break; case "countrycode": $output = @$ipdat->geoplugin_countryCode; break; } } } return $output; } echo ip_info("119.30.32.215", "Country"); ?><br><?php echo ip_info("119.30.32.215", "Country Code"); ?><br><?php echo ip_info("119.30.32.215", "State"); ?><br><?php echo ip_info("119.30.32.215", "City"); ?><br><?php echo ip_info("119.30.32.215", "Address"); ?><br><?php print_r(ip_info("119.30.32.215", "Location")); // Array ( [city] => Menlo Park [state] => California [country] => United States [country_code] => US [continent] => North America [continent_code] => NA ) ?>
What you say ? Lemme see your sample code.
Thanks! Hi guys. I'm very new to PHP, and I'm trying to create a simple mail script. Mail a friend A user will click an image on the site which will open a pop up box. They input their name and the email of the friend that they want to send the current URL to. The email will send the current URL via email and display a confirmation message once it has sent successfully. The friend will receive an email with a link to the URL. The problem The email part works fine, it's the URL in the message that is the issue. When the user clicks the 'Email a friend' it opens a popup box - which is where the URL is being grabbed from and emailed. Is there a way to grab the URL from the page before the popup? Here is my (rather amateur) code. Also, feel free to let me know if I can make improvements to it if anything seems a bit strange! The popup link: <a onclick="window.open(this.href,'win2','width=400,height=350,menubar=yes,resizable=yes'); return false;" title="E-mail" href="mailform/form.html">Send to a friend</a> The popup form: <html> <body> <form method="post" action="code.php"> Friends Email: <input name="email" type="text" /><br /> Your Name: <input name="name" type="text" /><br /> <input type="submit" /> </form> </body> </html> The PHP code: <?php // Declaring Variables $email = $_REQUEST['email'] ; $name = $_REQUEST['name']; $geturl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; $message = "Hello. $name has suggested a page for you to view on our website. Please click the following link: $geturl"; // Email Settings mail( $email, "Send page to a friend", $message, "From: Timaru District Council" ); header( "Location: http://www.c4clever.com/sandbox/mailform/sent.html" ); // Confirmation page (Change this to appropriate URL) ?> Feel free to test it out if you want to (http://www.c4clever.com/sandbox) Looking forward to replies, thanks in advance! I have this setup, but for some reason it displays the stats from user where it should display user1. Code: [Select] <?php $user = "S U O M I"; $user1 = "Tezz"; if(isset($_GET['user'])) { if(!empty($_GET['user'])) { $user = $_GET['user']; } } if(isset($_GET['user1'])) { if(!empty($_GET['user1'])) { $user1 = $_GET['user1']; } } //Skill Grabs $order = array("Overall", "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft", "Hunter", "Construction", "Summoning", "Dungeoneering"); $get = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user"); $get = explode("\n", $get); $i = 0; foreach ($order as $key => $value) { $value = strtolower($value); $temp = explode(",", $get[$i]); $temp = array("rank" => $temp[0], "level" => $temp[1], "exp" => $temp[2]); $stats[$value] = $temp; $eval = "\$$value = array(\$temp[\"rank\"], \$temp[\"level\"], \$temp[\"exp\"]);"; eval($eval); $i++; } //End Skill Grabs $order1 = array("Overall", "Attack", "Defence", "Strength", "Hitpoints", "Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching", "Fishing", "Firemaking", "Crafting", "Smithing", "Mining", "Herblore", "Agility", "Thieving", "Slayer", "Farming", "Runecraft", "Hunter", "Construction", "Summoning", "Dungeoneering1"); $get1 = file_get_contents("http://hiscore.runescape.com/index_lite.ws?player=$user1"); $get1 = explode("\n", $get1); $i1 = 0; foreach ($order1 as $key1 => $value1) { $value1 = strtolower($value1); $temp1 = explode(",", $get[$i1]); $temp1 = array("rank1" => $temp1[0], "level1" => $temp1[1], "exp1" => $temp1[2]); $stats1[$value1] = $temp1; $eval1 = "\$$value1 = array(\$temp1[\"rank1\"], \$temp1[\"level1\"], \$temp1[\"exp1\"]);"; eval($eval1); $i1++; } //End Skill Grabs echo "<h2>".$user."</h2>"; echo "<table border='1' cellpadding='5'>"; echo "<tr>"; echo "<td><b>Skills</b></td>"; echo "<td><b>Rank</b></td>"; echo "<td><b>Level</b></td>"; echo "<td><b>XP</b></td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Overall</b></td>"; echo "<td>".$overall[0]."</td>"; echo "<td>".$overall[1]."</td>"; echo "<td>".$overall[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Attack</b></td>"; echo "<td>".$attack[0]."</td>"; echo "<td>".$attack[1]."</td>"; echo "<td>".$attack[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Defence</b></td>"; echo "<td>".$defence[0]."</td>"; echo "<td>".$defence[1]."</td>"; echo "<td>".$defence[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Strength</b></td>"; echo "<td>".$strength[0]."</td>"; echo "<td>".$strength[1]."</td>"; echo "<td>".$strength[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Constitution</b></td>"; echo "<td>".$hitpoints[0]."</td>"; echo "<td>".$hitpoints[1]."</td>"; echo "<td>".$hitpoints[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Ranged</b></td>"; echo "<td>".$ranged[0]."</td>"; echo "<td>".$ranged[1]."</td>"; echo "<td>".$ranged[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Prayer</b></td>"; echo "<td>".$prayer[0]."</td>"; echo "<td>".$prayer[1]."</td>"; echo "<td>".$prayer[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Magic</b></td>"; echo "<td>".$magic[0]."</td>"; echo "<td>".$magic[1]."</td>"; echo "<td>".$magic[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Cooking</b></td>"; echo "<td>".$cooking[0]."</td>"; echo "<td>".$cooking[1]."</td>"; echo "<td>".$cooking[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Woodcutting</b></td>"; echo "<td>".$woodcutting[0]."</td>"; echo "<td>".$woodcutting[1]."</td>"; echo "<td>".$woodcutting[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Fletching</b></td>"; echo "<td>".$fletching[0]."</td>"; echo "<td>".$fletching[1]."</td>"; echo "<td>".$fletching[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Fishing</b></td>"; echo "<td>".$fishing[0]."</td>"; echo "<td>".$fishing[1]."</td>"; echo "<td>".$fishing[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Firemaking</b></td>"; echo "<td>".$firemaking[0]."</td>"; echo "<td>".$firemaking[1]."</td>"; echo "<td>".$firemaking[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Crafting</b></td>"; echo "<td>".$crafting[0]."</td>"; echo "<td>".$crafting[1]."</td>"; echo "<td>".$crafting[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Smithing</b></td>"; echo "<td>".$smithing[0]."</td>"; echo "<td>".$smithing[1]."</td>"; echo "<td>".$smithing[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Mining</b></td>"; echo "<td>".$mining[0]."</td>"; echo "<td>".$mining[1]."</td>"; echo "<td>".$mining[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Herblore</b></td>"; echo "<td>".$herblore[0]."</td>"; echo "<td>".$herblore[1]."</td>"; echo "<td>".$herblore[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Agility</b></td>"; echo "<td>".$agility[0]."</td>"; echo "<td>".$agility[1]."</td>"; echo "<td>".$agility[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Thieving</b></td>"; echo "<td>".$thieving[0]."</td>"; echo "<td>".$thieving[1]."</td>"; echo "<td>".$thieving[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Slayer</b></td>"; echo "<td>".$slayer[0]."</td>"; echo "<td>".$slayer[1]."</td>"; echo "<td>".$slayer[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Farming</b></td>"; echo "<td>".$farming[0]."</td>"; echo "<td>".$farming[1]."</td>"; echo "<td>".$farming[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Runecrafting</b></td>"; echo "<td>".$runecraft[0]."</td>"; echo "<td>".$runecraft[1]."</td>"; echo "<td>".$runecraft[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Hunter</b></td>"; echo "<td>".$hunter[0]."</td>"; echo "<td>".$hunter[1]."</td>"; echo "<td>".$hunter[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Construction</b></td>"; echo "<td>".$construction[0]."</td>"; echo "<td>".$construction[1]."</td>"; echo "<td>".$construction[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Summoning</b></td>"; echo "<td>".$summoning[0]."</td>"; echo "<td>".$summoning[1]."</td>"; echo "<td>".$summoning[2]."</td>"; echo "</tr>"; echo "<tr>"; echo "<td><b>Dungeoneering</b></td>"; echo "<td>".$dungeoneering[0]."</td>"; echo "<td>".$dungeoneering[1]."</td>"; echo "<td>".$dungeoneering[2]."</td>"; echo "</tr>"; echo "</table>"; echo "<h2>".$user1."</h2>"; echo "<table border=1 cellpadding=5>"; echo "<tr>"; echo "<td><b>Dungeoneering</b></td>"; echo "<td>".$dungeoneering1[0]."</td>"; echo "<td>".$dungeoneering1[1]."</td>"; echo "<td>".$dungeoneering1[2]."</td>"; echo "</tr>"; echo "</table>"; What is wrong with this code? Hello Guys, I have a question I have the following function that is located in a different file. I want to be able to use the $lat and $long in my main page how would I code it? Code: [Select] function toCoordinates($all_address) { $bad = array( " " => "+", "," => "", "?" => "", "&" => "", "=" => "" ); $all_address = str_replace(array_keys($bad), array_values($bad), $all_address); $data = new SimpleXMLElement(file_get_contents("http://maps.google.com/maps/geo?output=xml&q={$all_address}")); $coordinates = explode(",", $data->Response->Placemark->Point->coordinates); return array( "latitude" => $coordinates[0], "longitude" => $coordinates[1] ); } Tried this but it didn't work $all_address2 = toCoordinates($all_address); echo "$all_address2; Please advise... Thanks, Dan Hi, Im trying to grab some data from a XML generated by an external server. I know how to grab from XML without attributes, but I cant seem to wrap my head around the structure of this file. What would be easiest way to get the value of the "dbnr" field? Part of the XML file: Code: [Select] <data> <location> <field name="id" format="Long">xxxxxx</field> <field name="dbnr" format="Long">xxxxxx</field> <field name="jobnr" format="Long">xxxxxx</field> <field name="job_type" format="String" maxlen="50">xxxxxx</field> <field name="job_category" format="String" maxlen="50">xxxxxx</field> </location> </data> Hi guys really need some help. i have got this function. I am learning codeignitor. function uploadify() { $file = $this->input->post('filearray'); $data['json'] = json_decode($file); print_r($data); $name = $json->{'file_name'}; $this->files->add($name); $this->load->view('uploadify',$data); } this is the result i get from the print_r(). Array ( [json] => stdClass Object ( [file_name] => footer-icpn229.jpg [real_name] => footer-icpn2.jpg [file_ext] => .jpg [file_size] => 1.75 [file_path] => /home/codeig/public_html/files/footer-icpn229.jpg [file_temp] => /home/codeig/tmp/phpSupCpi ) ) What i am trying to do is pull the value filename out off the array and pass it into another vairable in the fucntion which is what i am trying to do with these two lines of code. $name = $json->{'file_name'}; $this->files->add($name); I keep getting this error what am i doing wrong? Undefined variable: json |