Jump to content

total noob

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

total noob's Achievements

Member

Member (2/5)

0

Reputation

  1. Hello to all I need help on parsing this string <?php "1" "+447980123456","+447980123456","","2009-06-03","13:15:17","hello world","Orange","843822651" "+447980123456","+447980123456","","2009-06-03","15:17:13","helloworld","Orange","843822652" "+447980123456","+447980123456","","2009-06-03","17:13:15","hello,world","Orange","843822653" ?> I've tried to use this code but it give's me a blank result.. I want to echo each element using foreach loop but it does not give me any result. can someone help me on this? this is the code <?php $file = '"1" "+447980123456","+447980123456","","2009-06-03","13:15:17","hello world","Orange","843822651" "+447980123456","+447980123456","","2009-06-03","15:17:13","helloworld","Orange","843822652" "+447980123456","+447980123456","","2009-06-03","17:13:15","hello,world","Orange","843822653" '; $toinks = 0; $array = explode(',',$file ); foreach($array as $key => $value) { $value = preg_replace('/#1#/','',$value); $value = preg_replace('/[^+0-9]/','',$value); if ($value != '' || $value != NULL) { if (preg_match('/^\+/',$value)) { $newarray[$toinks] = $value; $toinks++; } } } $wenkz = $newarray; print_r($wenkz); ?> ive tried using <?php foreach($file as $me){ echo $me; } or foreach($file as $me=> $pols){ echo $pols[1]; } ?> still it does not show me any result. Im nearing my deadline to finish my system. But im stuck on this.. Please help me! thanks in advance
  2. Last question sir what if <?php /*$myAray is equal to the arrays above*/ $qarray2 = $myAray['GetSMSInboundResponse']['SMSInbounds']['InboundSMS']; foreach($qarray2 as $key => $mnb){ if($key == "ID" && $key == "Originator") $id = "$key = $mnb"; $originator = "$key = $mnb"; } ?> Is the code above works? Im not in the house today so i can't test my code. Later i will test it.. thanks
  3. So sorry for giving a nonsense reply.. Thanks for the info my problem is somehow fix..
  4. Based on your code sir <?php <?php /*$myAray is equal to the arrays above*/ $qarray2 = $myAray['GetSMSInboundResponse']['SMSInbounds']['InboundSMS']; foreach($qarray2 as $key => $mnb){ echo "$key = $mnb"; } ?> ?> could i echo just 1 element on my array? thanks
  5. Im accessing each array separately sir however i would like to do it only in one foreach loop thats applicable to both arrays.. Is this possible sir? thanks
  6. This is my two arrays sir.. <?php /*First array*/ Array ( [GetSMSInboundResponse] => Array ( [Transaction] => Array ( [Code] => 1 [Description] => Transaction OK ) [sMSInbounds] => Array ( [inboundSMS] => Array ( [0] => Array ( [iD] => 3135899 [Originator] => +447537404702 [Destination] => +447537404702 [Keyword] => UCB2 [Date] => 2012-01-25 [Time] => 12:20:24 [body] => UCB2 test "SMS", with comma and qoutes for UCB.. ) [1] => Array ( [iD] => 3135903 [Originator] => +447537404702 [Destination] => +447537404702 [Keyword] => UCB2 [Date] => 2012-01-25 [Time] => 12:20:24 [body] => UCB2 test "SMS", with comma and qoutes for UCB.. the second message... ) ) ) ) ) /*Second array*/ Array ( [GetSMSInboundResponse] => Array ( [Transaction] => Array ( [Code] => 1 [Description] => Transaction OK ) [sMSInbounds] => Array ( [inboundSMS] => Array ( [iD] => 3135765 [Originator] => +447537404702 [Destination] => +447537404702 [Keyword] => UCB2 [Date] => 2012-01-25 [Time] => 12:09:08 [body] => UCB2 this is a test "sms", with commas.. Test onlt for UCB Function ) ) ) ) ?> the two arrays are a separate array.. Now below is my code for viewing the arrays <?php /*$myAray is equal to the arrays above*/ $qarray2 = $myAray['GetSMSInboundResponse']['SMSInbounds']['InboundSMS']; foreach($qarray2 as $mnb){ $q1 = $mnb['ID']; } ?> Now the code above works on my first array but im having trouble of getting the correct output for the second array.. Could you help me sir? thanks in advance
  7. Hello sir Im not very familiar with using mysql_real_escape_string can you give me an example on how can i implement it on my code? thanks
  8. This code does not work sir.. I think the error is cause by my array..
  9. Does some have any ideas? well, since you have named array keys, you must access them by their name, using integers will not work, if your array keys were the default integers, then your code would work. If i used a name i.e. echo $val['ID'] by getting the results of the array it wont echo any results... Im just curios where did it went wrong.. because $val isn't defined in your code. You Mean $keyws in your case Im so sorry that's not $val it was $keyws... Do you have any ideas why it cant view any results? all i see is a white page.. thanks
  10. Hello all I've been using implode function of php and suddenly i encounter a problem regarding it.. <?php $insertValues[] = "(default,'{$y}', '{$p}', '{$o}', '{$i}', '{$u}','AMM-40','test')"; $query_status = "INSERT INTO `mobile1_mn1`.`logs_inbound` (`log_id`, `originator`, `sender`, `date`, `time`, `message`, `company_id`, `keyword`) VALUES". implode(',',$insertValues); ?> When the information on $y,$p,$o,$i and $u does not have any single 'quotations' and commas it can save my information on database but when i have a string say for example the string is "he's good" and "Im, good" having a comma and quote it can't save my information anymore... can someone tell me why i have this problem? thanks in advance
  11. Does some have any ideas? well, since you have named array keys, you must access them by their name, using integers will not work, if your array keys were the default integers, then your code would work. If i used a name i.e. echo $val['ID'] by getting the results of the array it wont echo any results... Im just curios where did it went wrong..
  12. Thanks Drongo_III However i cant change the array anymore.. That array result was the result after parsing an XML string.. I have a hard time on getting the data on the array.. Im hoping that someone could solve this problem.. thanks guys..
  13. Wow great! thanks AyKay47! Im just wondering.. Why i cant get the correct data by using this? <?php foreach($qarray2 as $mnb => $keyws){ echo $val[0]. '<br/>' .$val[1]; } ?> this is the result.. Does some have any ideas?
  14. This is the original array.. <?php Array ( [GetSMSInboundResponse] => Array ( [Transaction] => Array ( [Code] => 1 [Description] => Transaction OK ) [sMSInbounds] => Array ( [inboundSMS] => Array ( [iD] => 3135765 [Originator] => +447537404702 [Destination] => +447537404702 [Keyword] => UCB2 [Date] => 2012-01-25 [Time] => 12:09:08 [body] => UCB2 this is a test "sms", with commas.. Test onlt for UCB Function ) ) ) ) ?> I simplified the above array hoping to get an easier array by doing this. <?php $qarray2 = $myAray['GetSMSInboundResponse']['SMSInbounds']['InboundSMS']; foreach($qarray2 as $keys){ echo $keys; } ?> However if i echo the array using this <?php $qarray2 = $myAray['GetSMSInboundResponse']['SMSInbounds']['InboundSMS']; foreach($qarray2 as $keys){ echo $keys[1]; } ?> or <?php $qarray2 = $myAray['GetSMSInboundResponse']['SMSInbounds']['InboundSMS']; foreach($qarray2 as $keys){ echo $keys['Body']; } ?> I cant get any results.. I would like to echo each data on a newline but im stuck on how to do it... Can someone help me? Thanks guys.. - thanks scootstah...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.