anonīms Posted June 8, 2012 Report Share Posted June 8, 2012 Vai ir iespējams kaut kā ielikt teiksim (-) pēc noteikta simbolu skaita? šajā gadījumā ir personas kods, kas ir viss kopā, bet domāju vai ar kādu vieglu paņēmienu var to panākt. Tā jau itkā var substr, bet domāju, ka mok ir kāds cits variants arī :) Paldies Link to comment Share on other sites More sharing options...
daGrevis Posted June 8, 2012 Report Share Posted June 8, 2012 Apvieno šitās divas funkcijas: http://php.net/manual/en/function.strpos.php http://php.net/manual/en/function.substr.php Link to comment Share on other sites More sharing options...
anonīms Posted June 8, 2012 Author Report Share Posted June 8, 2012 ay, es jau pa savam samočiju Testam un piemēram Jums $getData = new stdClass(); $getData->return->ownerCode = 10048912877; $personCode = array(substr($getData->return->ownerCode,0,6),substr($getData->return->ownerCode,6)); $getData->return->ownerCode = $personCode[0].'-'.$personCode[1]; print $getData->return->ownerCode; Link to comment Share on other sites More sharing options...
daGrevis Posted June 8, 2012 Report Share Posted June 8, 2012 Kas tas par lieku `return`? Link to comment Share on other sites More sharing options...
anonīms Posted June 8, 2012 Author Report Share Posted June 8, 2012 (edited) Tas ir testam te. Reāli šādi dati tiek atgriezti no fjas, kas nav Mūsu pusē. Vnk negribēju Jums rakstīt atsevišķi kodu un copy paste uztaisīju +$getData = new stdClass(); +$getData->return->ownerCode = 10048912877; $personCode = array(substr($getData->return->ownerCode,0,6),substr($getData->return->ownerCode,6)); $getData->return->ownerCode = $personCode[0].'-'.$personCode[1]; +print $getData->return->ownerCode; Edited June 8, 2012 by anonīms Link to comment Share on other sites More sharing options...
xPtv45z Posted June 8, 2012 Report Share Posted June 8, 2012 wordwrap! Link to comment Share on other sites More sharing options...
indoom Posted June 8, 2012 Report Share Posted June 8, 2012 vēl var $getData->return->ownerCode = implode('-', str_split($getData->return->ownerCode, 6)); bet wordwrap labāks Link to comment Share on other sites More sharing options...
anonīms Posted June 8, 2012 Author Report Share Posted June 8, 2012 Paldies. wordwrap izmantoju. Link to comment Share on other sites More sharing options...
Recommended Posts