PHP - Splitting An Iptc Array
I'll be creating a script that will get the keywords from uploaded pictures and what i cant figure out is how to actually get only the keywords from the iptc data this is the code i have for getting the iptc data right now:
Code: [Select] <?php $size = getimagesize('images/Sections/pinkpanthers/20102011/Session1/1-15-11/1.jpg', $info); if(isset($info['APP13'])) { $iptc = iptcparse($info['APP13']); var_dump($iptc); ?> } and this outputs Code: [Select] array(4) { ["1#090"]=> array(1) { [0]=> string(3) "%G" } ["2#000"]=> array(1) { [0]=> string(2) "" } ["2#025"]=> array(1) { [0]=> string(5) "Tyler" } ["2#080"]=> array(1) { [0]=> string(15) "Christian" } } all i want from the above string is the Tyler Similar TutorialsHi All How do I go about splitting a multidimensional array into seperate smaller ones? Currently I have $grade[region][userid]=value. I'd like to split as $region1[userid]=value $region2[userid]=value $region3[userid]=value $region4[userid]=value $region5[userid]=value $region6[userid]=value Is there an inbuilt function for this? Hey guys,
I have an array of names sorted alphabetically. I'm trying to loop through them and create new arrays keyed by the letters of the alphabet containing the names which start with that letter.
so in the end i'm trying to create something like this:
$newarray = array( 'a' => array('anna','alan','andrew'),
'b' => array('bert','ben','bob'), 'c' => array('cait','carry'), etc,etc ); thanks I'm using smarty and php to collect parameters from a user defined tag in cmsms that looks like this... Code: [Select] {schedule date="2010-11-13" time="7:05 p.m." location="Evansville" home="Oakland City" vs="Evansville" winner="University of Evansville" results="82-42"} {schedule date="2010-11-15" time="7:00 p.m." location="Oakland City" home="Oakland City" vs="OSU-Lima" winner="OSU-Lima" results="68-67 2OT"} etc... As you can see each {schedule tag above has the same home="" value. Thats because its schedule dates just for THAT team (i.e. Oakland City). So I may have 10 of these tags on the same page. But I also have other places where the schedule tag is used with a different $home name for another team. So basically I'm calling ALL these schedule tags into one for loop like this... Code: [Select] for ($i=0; $i < count($params['date']); $i++) { $date= $params['date']; $time=$params['time']; $location= $params['location']; $home= $params['home']; $vs= $params['vs']; $winner= $params['winner']; $results= $params['results']; $gameinfo = array("date", "time","location","home","vs","winner","results"); $game_info = compact($gameinfo); } All I want to do is spit back out the total wins for each $home team. I am pulling out my hair out trying to get this thing to work but no luck yet, even though I see a little light. This is what I got so far... Code: [Select] for ($i=0; $i < count($params['date']); $i++) { $date= $params['date']; $time=$params['time']; $location= $params['location']; $home= $params['home']; $vs= $params['vs']; $winner= $params['winner']; $results= $params['results']; $gameinfo = array("date", "time","location","home","vs","winner","results"); $game_info = compact($gameinfo); if($home == $winner) { $wins = array('team' => $winner, 'win' => count($winner)); } } $smarty->append('mwins',$wins); print '<pre>'; print_r($wins); print '</pre>'; and I get this... Code: [Select] Array ( [0] => Array ( [team] => Oakland City [win] => 1 ) [1] => Array ( [team] => Oakland City [win] => 1 ) [2] => Array ( [team] => Oakland City [win] => 1 ) [3] => Array ( [team] => Oakland City [win] => 1 ) [4] => Array ( [team] => Oakland City [win] => 1 ) [5] => Array ( [team] => Oakland City [win] => 1 ) [6] => Array ( [team] => Oakland City [win] => 1 ) [7] => Array ( [team] => Oakland City [win] => 1 ) [8] => Array ( [team] => Oakland City [win] => 1 ) [9] => Array ( [team] => Oakland City [win] => 1 ) [10] => Array ( [team] => Oakland City [win] => 1 ) [11] => Array ( [team] => Oakland City [win] => 1 ) [12] => Array ( [team] => Oakland City [win] => 1 ) [13] => Array ( [team] => Oakland City [win] => 1 ) [14] => Array ( [team] => Oakland City [win] => 1 ) [15] => Array ( [team] => Oakland City [win] => 1 ) [16] => Array ( [team] => Oakland City [win] => 1 ) [17] => Array ( [team] => Southern Indiana [win] => 1 ) [18] => Array ( [team] => Southern Indiana [win] => 1 ) [19] => Array ( [team] => Southern Indiana [win] => 1 ) [20] => Array ( [team] => Southern Indiana [win] => 1 ) [21] => Array ( [team] => Southern Indiana [win] => 1 ) [22] => Array ( [team] => Southern Indiana [win] => 1 ) [23] => Array ( [team] => Southern Indiana [win] => 1 ) [24] => Array ( [team] => Southern Indiana [win] => 1 ) [25] => Array ( [team] => Southern Indiana [win] => 1 ) [26] => Array ( [team] => Southern Indiana [win] => 1 ) [27] => Array ( [team] => Southern Indiana [win] => 1 ) [28] => Array ( [team] => Southern Indiana [win] => 1 ) [29] => Array ( [team] => Southern Indiana [win] => 1 ) [30] => Array ( [team] => Southern Indiana [win] => 1 ) [31] => Array ( [team] => Southern Indiana [win] => 1 ) [32] => Array ( [team] => Southern Indiana [win] => 1 ) [33] => Array ( [team] => Southern Indiana [win] => 1 ) [34] => Array ( [team] => Southern Indiana [win] => 1 ) [35] => Array ( [team] => Southern Indiana [win] => 1 ) [36] => Array ( [team] => Southern Indiana [win] => 1 ) [37] => Array ( [team] => Southern Indiana [win] => 1 ) etc... I want to take all the [win] values for each [team] and add them up this way my final array looks like this... Code: [Select] Array ( [0] => Array ( [team] => Oakland City [win] => 18 ) [1] => Array ( [team] => Southern Indiana [win] => 24 ) I know I'm so close but don't know how to solve the condition I need. Any suggestions would be great!!! bh I am trying to get rows from MYSQL table (attachment) based on: Select last five rows where status_id = 1 Select last two rows where status_id = 2*I did use UNION with two SELECT queries to get whole data as one array. Now on PHP side... I have first block for rows having status_id 1 so if there are rows having status_id 1 then PHP should display the data otherwise if there is no row having status_id 1 then PHP should print NO DATA only once. I have second block for rows having status_id 2 so if there are rows having status_id 2 then PHP should display the data otherwise if there is no row having status_id 2 then PHP should print NO DATA only once. I did use foreach loop then within loop i did use if condition to check status_id of rows. it works fine when i omit NO DATA part but when i add it. the result shows both rows and NO DATA in first block when there are one or more rows having status_id 1 but no row having status_id 2 Which made me believe that i was doing it the wrong way. Please guide me *PS: I know its PHP section the thread should be related to PHP problem but... is it right to use UNION in query? or should i post a new thread in relevant section for guidance?
Trying to do something that I think should be very simple. Let's assume that I have an array populated with the numbers 1 to 24 for this example. I need to output these items in 4 columns to accomodate my CSS layout but still have them read from left to right, top to bottom. I also want this to be somewhat dynamic - I'm okay hardcoding it to split into 4 columns, but need it to handle any number of items in the array. I'm not sure if the best way to do this would be to split the original array into an array for each of the 4 columns, or to loop through the original array 4 times and output items 1+4, 2+4, and so on. Or maybe I should be using array_filter with some custom callback functions. I'm fine with any solution. The end result is echoing the array in the following groupings so I can surround each column with the appropriate column HTML for layout (in this case the array actually contains IMG urls): Column 1: 1, 5, 9, 13, 17, 21 Column 2: 2, 6, 10, 14, 18, 22 Column 3: 3, 7, 11, 15, 19, 23 Column 4: 4, 8, 12, 16, 20, 24 Any help would be appreciated! This one is driving me nuts and I know it should be relatively easier. Guess I should stick to HTML + CSS. http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/get_hit_list?user_id=100000952273457&target_id=100000556624340&level=300&auth_key=cb07c7575b38df48d82dd53619385faa884db5a2 When going to this URL, it gives entries between <entry> and </entry>, what I am trying to do, is collect the <user_id> ONLY if the <amount> is over a certain value. Any ideas to how I could do this (I am a complete PHP noob). All help is appreciated Heya guys! What's up? OK here's my problem: I got a variable, $var1, which is to have values like "groan,100,200,350,50" I need to know how to split this $var1 into $split1, $split2, $split3, $split4, $split5, where $split1 = "groan"; $split2 = "100"; $split3 = "200"; $split4 = "350"; $split5 = "50"; Thanks in advance people! P.S. In my case I am going to use some of the values for calculations. So I don't think that its easy with arrays, which are difficult for me to understand . P.S.S. When I am retrieving data from the database, many variables like $var1 that need to be split are being extracted. I hope that you understand. Thanks and Regards, Thauwa Okay I need a little bit of help on this as strings constantly confuse me and reading tutorials actually got me a bit more loss then before. I have developed this mod that has become pretty popular and I'm debugging it. What I have are two variables. $username (The user's username, no html markup in it) $musername (The user's username, with html markup in it) So for example: $musername = <b><u>$username</u></b> The php code above would be the equivolant to what $musername is equal to. What I need to do is create an array or two variables, whatever is easier and grab all that html markup. The first variable would be all the html or anything really before the $username variable, and the other would take all of that html after the $username variable. I need to store those html markups in either two seperate variables or an array so i can call upon it later in the script. I need this to fix a bug issue. The sample string is KmSO4 Every upper case alphabet should be identified and splitted until another upper case alphabet comes. the string should be splitted so that output array looks like this Array ( => Km [1] => S [2]=>O4 ) can any one help regarding this issue? I have a string like this: Code: [Select] Something,Somthing Else,"keyword1,keyword2,keyword3",Yet another I need to split that string by the ,. However, I need the data that is n the quotes to remain as one even though it has commas because it is one item. I assume I need to use preg_split and have tried some code but none of it seems to work properly. If anyone has a better method or knows how I can split this up using preg_split the help is appreciated. I could use some suggestions on how to break up my HTML and PHP. Currently I have a file called "payment_form.php" It looks like this... Code: [Select] <body> <?php // HANDLE FORM. if (isset($_POST['submitted'])){ // Handle Form. // Determine if any errors. if (empty($errors)){ // Process Payment. // PHP code to send payment to Payment Gateway... // Do not return to Payment Form!!! exit(); } } ?> <!-- HTML PAYMENT FORM --> <form id="payment" action="" method="post"> <fieldset> <legend>Billing Details</legend> <ol> <!-- First Name --> <li> <label for="firstName">First Name:</label> <input id="firstName" name="firstName" class="text" type="text" maxlength="20" value="<?php echo $firstName; ?>" /> <?php if (!empty($errors['firstName'])){ echo '<span class="error">' . $errors['firstName'] . '</span>'; } ?> </li> I would like to keep the Form Validation PHP in the same file as the HTML Form so the user isn't ping-ponged between two pages if they make data entry errors. However, I am thinking it would be better to break out the Payment Processing PHP and place that in a different file. How should I do that? Maybe I could add a Redirect after this code... Code: [Select] if (empty($errors)){ // Process Payment. // PHP code to send payment to Payment Gateway... Suggestions welcome!! Thanks, Debbie Hi guys Say for example I have a text field with value 20/10/2011 how do I define it so that $x=20, $y=10 and $z=2011 so that I have three variables Thanks I have a text field that contains the following (example text used): 1 2 3 4 5 6 As you can see the first few are split by a single space, with the last few numbers split by a double space. My aim is to put each of these numbers into a table in a MYSQL database. But I'm having trouble breaking them up. Hi Guys, does anyone know how split a text into groups depending on how many words are in the text e.g $text = "If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. "; I want a maximium of 5 words in each group, so the above text will be split as such $text1 = 'If you are new to'; $text2 = 'PHP and want to get'; $text3 = 'some idea of how it '; $text4 = 'works, try the introductory tutorial.'; But if I want a maximium of 10 words in each group, so the above text will then be split like this $text1 = 'If you are new to PHP and want to get'; $text2 = 'some idea of how it works, try the introductory tutorial.'; $text3 = ''; $text4 = ''; Is this possible? Please any help will be much appreciated thanks Hello, I have a variable that holds a piece of text that looks something like this: "world,blue,big". Is there anyway to split the text into the separate words as an array, and remove the commas? Code: [Select] $text_to_split = "world,blue,big"; $splitArray = array(); //Do some kind of php function that splits text\\ echo splitArray[0]; // world echo splitArray[1]; //blue echo splitArray[2]; //big Would appreciate it, thanks I have a problem displaying the results of a table, It shows them in one long list and I'd like them to show as 2 or 3. I had a look around and the most favoured way to this I found was to split the results either by odd/even or using percentages but Im having trouble implementing it into my script. How would I go about adding the odd/even way to this: <?php $query = mysql_query('SELECT * FROM users ORDER BY Username'); while ($row = mysql_fetch_array($query)) { if ($row['UserID']) ?> <b>Username:</b> <span class=class1><a href="aeditprofile.php?username=<? echo $row['Username'] ?>"><? echo $row['Username'] ?></a></span><br> <b>Group:</b> <? echo $row['Level'] ?></color><br /><hr> <?php } ?> Essentially I'm after getting something like this: Name Name Name Group Group Group and so on down the page.... Hi, I am trying to split a string into an array and then seeing what sort of data it is. eg; I get the following string Quote api=somerandomkeyhere&user=someuser&password=somehashvaluehere&type=somethingelse I need to be able to put this into an array so in this case Code: [Select] myarray[type]=somethingelse myarray[api]=somerandomkeyhere myarray[user]=someuser myarray[password]=somehashvaluehere but it could include many more/less different value's separated by the & symbol. Thanks, -mme I have a database full of strings which are basically URL's with ports, so by default my strings look like: http://example.com:1234/ http://example2.com:3030/ http://example.com:9876/ http://example.com:5432/ What I am looking for is a way to separate the host from the post so the output would be something like: Host: example.com Port: 1234 Note: I once need to check one string at a time, so what I am after is something like: $string = "http://example.com:1234/"; And the result would be something like: $host (would be example.com without http://) $port (would be the port without ending /) Any help would be great Thanks for your time reasing this. Hi, I have a form with a dropdown Code: [Select] <select name="county" id="county"> <option selected="selected">Choose A County</option> <option value="1">Dublin</option> <option value="2">Westmeath</option> <option value="3">Galway</option> <option value="4">Roscommon</option> </select> What I am trying to do is seperate for example the value '1' and the option 'Dublin'. The results are passed to hidden field on a second form page. This is what I have, but it doesnt seem to be working... Code: [Select] <input type="hidden" name="county" value="<?php echo ($_POST['county']); ?>" /> <input type="hidden" name="county1" value="<?php echo ($_POST['county']); ?>" /> so I was wondering if anyone might be able to give me a pointer in the right direction. I have tried using an array on the processing page to split it but its not working either.. like this: Code: [Select] $county = (float) $_POST['county']; $county1 = in_array($county, array(1, 2, 3, 4)) ? $county : 5; $county1 = $_POST['1']='Dublin'; $county1 = $_POST['2']='Westmeath'; $county1 = $_POST['3']='Galway'; $county1 = $_POST['4']='Roscommon'; $county1 = $_POST['5']='Cork'; I have been trying to get this to work for a few days and I have searched everywhere for the answer, but I can't find it anywhere. I would be so grateful if someone could help me with this and it the last part I need to do before I move on to the next part of my project. Thanking you Eoin hey guys just a quick onei having a blank moment i have an array at themoment pulling from a database. i basically want to split this array based on a min and max value. divide it equally and then give it a value on each smaller array and where each array starts... to make it clearer - say i have an array with 600 values in i want it split up into 8 smaller arrays link so Array ( => Array ( [start] => 0 [split] => 75 ) [1] => Array ( [start] => 75 [split] => 75 ) [2] => Array ( [start] => 150 [split] => 75 ) carrying on till the end ) how would i do this. |